kms

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: 14 Imported by: 0

Documentation

Overview

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Package kms

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommit

func NewCommit(data []byte) (Commitments, Nonce, 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 Commitments

type Commitments [32]byte

Avoid Rogue Key Attacks

func (*Commitments) MarshalText

func (c *Commitments) MarshalText() ([]byte, error)

func (*Commitments) UnmarshalText

func (c *Commitments) UnmarshalText(input []byte) error

func (*Commitments) Verify

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

type DLogProof

type DLogProof struct {
	PublicShare       []byte   `json:"publicshare"`
	PkRandComm        []byte   `json:"pkrandcomm"`
	ChallengeResponse *big.Int `json:"challengeresp"`
}

func (*DLogProof) Verify

func (proof *DLogProof) Verify() error

type KenGenParams

type KenGenParams struct {
	Curve         elliptic.Curve
	Q             *big.Int
	Q3            *big.Int
	QSquared      *big.Int
	NPaillierBits int
	RangeSecBits  int
}

type KeyGenCommWitness

type KeyGenCommWitness struct {
	PkCommitNonce Nonce
	ZkPokNonce    Nonce
	PublicShare   []byte // Party1 publicKey
	Proof         *DLogProof
}

type KeyGenParty1FirstMsg

type KeyGenParty1FirstMsg struct {
	PkCommit    Commitments `json:"pkcommit"`
	ZkPokCommit Commitments `json:"zkpokcommit"`
}

type KeyGenParty1FourthMsg

type KeyGenParty1FourthMsg struct {
	PdlDecommit *Party1PDLDecommit `json:"pdldecommit"`
}

type KeyGenParty1SecondMsg

type KeyGenParty1SecondMsg struct {
	Witness     *KeyGenCommWitness `json:"witness"`
	Ckey        *big.Int           `json:"ckey"`
	CKProof     *NICorrectKeyProof `json:"ckproof"`
	RPCtxtPairs []CiphertextPair   `json:"rpctx"`
}

type KeyGenParty1ThirdMsg

type KeyGenParty1ThirdMsg struct {
	Party1PdlMsg1 *Party1PDLFirstMsg `json:"pdlmsg1"`
	RPProofPairs  []ProofPair        `json:"rpproof"`
}

type KeyGenParty2FirstMsg

type KeyGenParty2FirstMsg struct {
	Proof      *DLogProof  `json:"dlogproof"`
	RPChalComm Commitments `json:"rpchalcomm"`
}

type KeyGenParty2SThirdMsg

type KeyGenParty2SThirdMsg struct {
	PdlDecomm *Party2PDLDecommit `json:"pdldecomm"`
}

type KeyGenParty2SecondMsg

type KeyGenParty2SecondMsg struct {
	Pdl1stMsg   *Party2PDLFirstMsg `json:"pdlmsg1"`
	RPChallenge BitSlice           `json:"rpchallenge"`
	RPChalNonce Nonce              `json:"rpchalnonce"`
}

type MasterKey1

type MasterKey1 struct {
	Sk1 *ecdsa.PrivateKey //
	Pk  *ecdsa.PublicKey
	Pk2 *ecdsa.PublicKey
	PSk *paillier.PrivateKey // the privateKey for paillier
}

MasterKey1 the privatekey for the server

func (*MasterKey1) MarshalJSON

func (k *MasterKey1) MarshalJSON() ([]byte, error)

func (*MasterKey1) UnmarshalJSON

func (k *MasterKey1) UnmarshalJSON(input []byte) error

type MasterKey2

type MasterKey2 struct {
	Sk2 *ecdsa.PrivateKey // ecdsa privateKey

	Pk *ecdsa.PublicKey

	Pk1  *ecdsa.PublicKey
	Ckey *big.Int

	PPK *paillier.PublicKey // the publicKey for paillier
}

MasterKey2 the privateKey for client

func (*MasterKey2) MarshalJSON

func (k *MasterKey2) MarshalJSON() ([]byte, error)

func (*MasterKey2) UnmarshalJSON

func (k *MasterKey2) UnmarshalJSON(input []byte) error

type NICorrectKeyProof

type NICorrectKeyProof struct {
	PPk   *paillier.PublicKey `json:"paillier"`
	Sigma []*big.Int          `json:"sigma"`
}

func NewCorrectKeyProof

func NewCorrectKeyProof(p1Paillier *Party1Paillier) (*NICorrectKeyProof, error)

func (*NICorrectKeyProof) Verify

func (p *NICorrectKeyProof) Verify() error

type Nonce

type Nonce [32]byte

func (*Nonce) MarshalText

func (n *Nonce) MarshalText() ([]byte, error)

func (*Nonce) UnmarshalText

func (n *Nonce) UnmarshalText(input []byte) error

type PDLChallenge

type PDLChallenge struct {
	CPrime  []byte
	ABComm  Commitments
	A       *big.Int
	B       *big.Int
	ABNonce Nonce
	Q       []byte
}

type Party1Generator

type Party1Generator struct {
	Sk1Puk ecdsa.PublicKey

	X2 *ecdsa.PublicKey

	// Range Proof
	RPProver *RangeProofProver
	// contains filtered or unexported fields
}

func (*Party1Generator) KeyGenMaster

func (g *Party1Generator) KeyGenMaster() (*MasterKey1, error)

func (*Party1Generator) KeyGenPhase1

func (g *Party1Generator) KeyGenPhase1() ([]byte, error)

func (*Party1Generator) KeyGenPhase2

func (g *Party1Generator) KeyGenPhase2(msg []byte) ([]byte, error)

func (*Party1Generator) KeyGenPhase3

func (g *Party1Generator) KeyGenPhase3(msg []byte) ([]byte, error)

func (*Party1Generator) KeyGenPhase4

func (g *Party1Generator) KeyGenPhase4(msg []byte) ([]byte, error)

type Party1PDLDecommit

type Party1PDLDecommit struct {
	AlphaNonce Nonce  `json:"alphanonce"`
	AlphaPk    []byte `json:"alphapk"`
}

type Party1PDLFirstMsg

type Party1PDLFirstMsg struct {
	AlphaComm Commitments `json:"alphacomm"`
}

type Party1Paillier

type Party1Paillier struct {
	// contains filtered or unexported fields
}

func (*Party1Paillier) PDLFirstStage

func (*Party1Paillier) PDLSecondStage

func (p *Party1Paillier) PDLSecondStage(p2Decomm *Party2PDLDecommit, p2PdlMsg1 *Party2PDLFirstMsg, x1 *ecdsa.PrivateKey, alpha *ecdsa.PrivateKey) error

type Party1SignCtx

type Party1SignCtx struct {
	// contains filtered or unexported fields
}

func NewParty1SignCtx

func NewParty1SignCtx(sk *MasterKey1, hash []byte) *Party1SignCtx

func (*Party1SignCtx) SignPhase1

func (ctx *Party1SignCtx) SignPhase1(msg []byte) ([]byte, error)

func (*Party1SignCtx) SignPhase2

func (ctx *Party1SignCtx) SignPhase2(msg []byte) ([]byte, error)

type Party2Generator

type Party2Generator struct {
	Sk2Puk ecdsa.PublicKey

	// Party2 公钥
	X1 *ecdsa.PublicKey
	// contains filtered or unexported fields
}

func (*Party2Generator) KeyGenMaster

func (g *Party2Generator) KeyGenMaster() (*MasterKey2, error)

func (*Party2Generator) KeyGenPhase1

func (g *Party2Generator) KeyGenPhase1(msg []byte) ([]byte, error)

func (*Party2Generator) KeyGenPhase2

func (g *Party2Generator) KeyGenPhase2(msg []byte) ([]byte, error)

func (*Party2Generator) KeyGenPhase3

func (g *Party2Generator) KeyGenPhase3(msg []byte) ([]byte, error)

func (*Party2Generator) KeyGenPhase4

func (g *Party2Generator) KeyGenPhase4(msg []byte) error

type Party2PDLDecommit

type Party2PDLDecommit struct {
	A       *big.Int `json:"a"`
	B       *big.Int `json:"b"`
	ABNonce Nonce    `json:"abnonce"`
}

type Party2PDLFirstMsg

type Party2PDLFirstMsg struct {
	CPrime []byte      `json:"cprime"`
	ABComm Commitments `json:"abcomm"`
}

type Party2Paillier

type Party2Paillier struct {
	// contains filtered or unexported fields
}

func (*Party2Paillier) PDLChallenge

func (p *Party2Paillier) PDLChallenge(pubShare *ecdsa.PublicKey) (*Party2PDLFirstMsg, *PDLChallenge, error)

func (*Party2Paillier) PDLDecommit

func (p *Party2Paillier) PDLDecommit(challenge *PDLChallenge) *Party2PDLDecommit

func (*Party2Paillier) VerifyPDL

func (p *Party2Paillier) VerifyPDL(alphaComm *Commitments, pdlDecomm *Party1PDLDecommit, challenge *PDLChallenge) error

type Party2SignCtx

type Party2SignCtx struct {
	// contains filtered or unexported fields
}

func NewParty2SignCtx

func NewParty2SignCtx(sk *MasterKey2, hash []byte) *Party2SignCtx

func (*Party2SignCtx) GetSignature

func (ctx *Party2SignCtx) GetSignature() (*big.Int, *big.Int)

func (*Party2SignCtx) SignPhase1

func (ctx *Party2SignCtx) SignPhase1() ([]byte, error)

func (*Party2SignCtx) SignPhase2

func (ctx *Party2SignCtx) SignPhase2(msg []byte) ([]byte, error)

func (*Party2SignCtx) SignPhase3

func (ctx *Party2SignCtx) SignPhase3(msg []byte) error

type ProofPair

type ProofPair struct {
	J  byte     `json:"j"`
	W1 *big.Int `json:"w1,omitempty"`
	R1 *big.Int `json:"k1,omitempty"`
	W2 *big.Int `json:"w2,omitempty"`
	R2 *big.Int `json:"r2,omitempty"`
}

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 Commitments
	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 Commitments, 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      Commitments
	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 SignParty1FirstMsg

type SignParty1FirstMsg struct {
	R1Proof *DLogProof `json:"r1proof"`
}

type SignParty1SecondMsg

type SignParty1SecondMsg struct {
	S *big.Int
}

type SignParty2FirstMsg

type SignParty2FirstMsg struct {
	R2Commit    Commitments `json:"r2commit"`
	R2PokCommit Commitments `json:"r2pokcomm"`
	Hash        []byte      `json:"hash"`
}

type SignParty2SecondMsg

type SignParty2SecondMsg struct {
	Witness *SignRCommWitness `json:"witness"`
	S1      *big.Int          `json:"s1"`
}

type SignRCommWitness

type SignRCommWitness struct {
	R2CommNonce Nonce
	R2PokNonce  Nonce
	R2Share     []byte
	Proof       *DLogProof
}

Jump to

Keyboard shortcuts

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