pairing

package
v0.0.0-...-aafbcf9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateSigmaI

func CalculateSigmaI(param CalculateSigmaIParams) (*bls12_381_ecc.G1Affine, error)

CalculateSigmaI calculate sigma_i using each segment and private key sigma_i = sk * ( H(v||i) + SHA256(mi||r_j)*u*g1 )

func G1FromByte

func G1FromByte(sigma []byte) (*bls12_381_ecc.G1Affine, error)

G1FromByte retrieve G1 point from bytes

func G1ToByte

func G1ToByte(sigma *bls12_381_ecc.G1Affine) []byte

G1ToByte convert G1 point to byes

func G1sFromBytes

func G1sFromBytes(gs [][]byte) ([]*bls12_381_ecc.G1Affine, error)

G1sFromBytes retrieve G1 point list from bytes

func GenKeyPair

func GenKeyPair() (*PrivateKey, *PublicKey, error)

GenKeyPair generate a random private/public key pair for client

func GenerateChallenge

func GenerateChallenge(indexList []int, round int64, privkey *PrivateKey) ([]*big.Int, []*big.Int, []byte, error)

GenerateChallenge generate a random challenge using index numbers for a specified round challenge = {index}, {vi}, randNum

func IntListFromBytes

func IntListFromBytes(intList [][]byte) []*big.Int

IntListFromBytes retrieve bit int list from bytes

func IntListToBytes

func IntListToBytes(intList []*big.Int) [][]byte

IntListToBytes convert bit int list to bytes

func PrivateKeyToByte

func PrivateKeyToByte(privkey *PrivateKey) []byte

PrivateKeyToByte convert private key to byes

func Prove

Prove generate a proof by challenge material sigma = v1*sigma1 + ... + vc*sigmac mu = (v1*SHA(m1||r_j) + ... + vc*SHA256(mc||r_j)) * g1 proof = {sigma, mu}

func PublicKeyToByte

func PublicKeyToByte(pubkey *PublicKey) []byte

PublicKeyToByte convert public key to byes

func RandomWithinOrder

func RandomWithinOrder() (*big.Int, error)

RandomWithinOrder generate a random number smaller than the order of G1/G2

func Verify

func Verify(param VerifyParams) (bool, error)

Verify verify the proof e(sigma, g2) = e( (v1*H(v||index_1) + ... + vc*H(v||index_c)) + u*mu, pk)

Types

type CalculateSigmaIParams

type CalculateSigmaIParams struct {
	Content []byte      // file content
	Index   *big.Int    // file segment index
	RandomV *big.Int    // a random V
	RandomU *big.Int    // a random U
	Privkey *PrivateKey // client private key
	Round   int64       // challenge round
}

CalculateSigmaIParams parameters required to calculate sigma_i for each segment

func CalculateSigmaIParamsFromBytes

func CalculateSigmaIParamsFromBytes(content, index, randomV, randomU, privkey []byte, round int64) CalculateSigmaIParams

CalculateSigmaIParamsFromBytes retrieve CalculateSigmaIParams from bytes

type PrivateKey

type PrivateKey struct {
	X *big.Int
}

PrivateKey pairing based challenge private key

func PrivateKeyFromByte

func PrivateKeyFromByte(privkey []byte) *PrivateKey

PrivateKeyFromByte retrieve private key from byes

type ProofParams

type ProofParams struct {
	Content       [][]byte                  // file contents
	Indices       []*big.Int                // {i} index list
	RandomVs      []*big.Int                // {v_i} random challenge number list
	Sigmas        []*bls12_381_ecc.G1Affine // {sigma_i} list in storage
	RandThisRound []byte                    // random number for this challenge round
}

ProofParams parameters required to generate proof

func ProofParamsFromBytes

func ProofParamsFromBytes(content, indices, randVs, sigmas [][]byte, rand []byte) (ProofParams, error)

ProofParamsFromBytes retrieve ProofParams from bytes

type PublicKey

type PublicKey struct {
	P *bls12_381_ecc.G2Affine
}

PublicKey pairing based challenge public key

func PublicKeyFromByte

func PublicKeyFromByte(pubkey []byte) (*PublicKey, error)

PublicKeyFromByte retrieve public key from byes

type VerifyParams

type VerifyParams struct {
	Sigma    *bls12_381_ecc.G1Affine // sigma in proof
	Mu       *bls12_381_ecc.G1Affine // mu in proof
	RandomV  *big.Int                // a random V
	RandomU  *big.Int                // a random U
	Indices  []*big.Int              // {i} index list
	RandomVs []*big.Int              // {v_i} random challenge number list
	Pubkey   *PublicKey              // client public key
}

VerifyParams parameters required to verify a proof

func VerifyParamsFromBytes

func VerifyParamsFromBytes(sigma, mu, randV, randU, pubkey []byte, indices, randVs [][]byte) (VerifyParams, error)

VerifyParamsFromBytes retrieve VerifyParams from bytes

Jump to

Keyboard shortcuts

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