experimental

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteVal

func ByteVal(u8 uints.U8) int

func CreateBaseCaseProof

func CreateBaseCaseProof(outerField, innerField *big.Int, fullTxBytes []byte, txnIdBytes [32]byte, innerCcs constraint.ConstraintSystem, provingKey native_groth16.ProvingKey) (
	witness.Witness,
	native_groth16.Proof,
	error,
)

func CreateBaseCaseWitness

func CreateBaseCaseWitness(
	fullTxBytes []byte,
	innerField *big.Int,
) (witness.Witness, error)

func CreateTxWitness

func CreateTxWitness(
	fullTxBytes []byte,
) (witness.Witness, error)

func SetupTxLib(innerField *big.Int) (constraint.ConstraintSystem, native_plonk.ProvingKey, native_plonk.VerifyingKey, error) {

	baseCcs, err := frontend.Compile(innerField, scs.NewBuilder,
		&SigCircuitBaseCase[sw_bls12377.ScalarField, sw_bls12377.G1Affine, sw_bls12377.G2Affine, sw_bls12377.GT]{})

	if err != nil {
		return nil, nil, nil, err
	}

	srs, srsLagrange, err := unsafekzg.NewSRS(baseCcs)

	if err != nil {
		return nil, nil, nil, err
	}

	innerPK, innerVK, err := native_plonk.Setup(baseCcs, srs, srsLagrange)
	if err != nil {
		return nil, nil, nil, err
	}
	return baseCcs, innerPK, innerVK, nil
}

func CreateTxProof(fullTxBytes []byte, innerCcs constraint.ConstraintSystem, provingKey native_plonk.ProvingKey) (

witness.Witness,
native_plonk.Proof,
error,

) {

	innerField := ecc.BLS12_377.ScalarField()
	outerField := ecc.BW6_761.ScalarField()

	genesisWitness, err := CreateTxWitness(fullTxBytes)
	if err != nil {
		return nil, nil, err
	}

	proof, err := native_plonk.Prove(innerCcs, provingKey, genesisWitness, plonk.GetNativeProverOptions(outerField, innerField))

	return genesisWitness, proof, err
}

Types

type G1Affine

type G1Affine = sw_bls24315.G1Affine

type G2Affine

type G2Affine = sw_bls24315.G2Affine

type GTEl

type GTEl = sw_bls24315.GT

type ScalarField

type ScalarField = sw_bls24315.ScalarField

type ScalarField = sw_bn254.ScalarField type G1Affine = sw_bn254.G1Affine type G2Affine = sw_bn254.G2Affine type GTEl = sw_bn254.GTEl

type SigCircuit

type SigCircuit[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	PreviousProof   groth16.Proof[G1El, G2El]
	PreviousVk      groth16.VerifyingKey[G1El, G2El, GtEl] `gnark:"-"` // constant verification key
	PreviousWitness groth16.Witness[FR]

	//private params
	TxPreImage [128]uints.U8
	ImageHash  [32]uints.U8 `gnark:",public"` //public input for proof verification
}

[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT]

func (*SigCircuit[FR, G1El, G2El, GtEl]) Define

func (circuit *SigCircuit[FR, G1El, G2El, GtEl]) Define(api frontend.API) error

type SigCircuitBaseCase

type SigCircuitBaseCase[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	//private params
	TxPreImage [128]uints.U8

	//public params
	//double-sha256 hash of the concatenation of above fields. Not reversed, so not quite a TxId
	ImageHash [32]uints.U8 `gnark:",public"` //shahash of the scriptPubkey. Preserve between IVC rounds.
}

func (*SigCircuitBaseCase[FR, G1El, G2El, GTEl]) Define

func (circuit *SigCircuitBaseCase[FR, G1El, G2El, GTEl]) Define(api frontend.API) error

type TxCircuit

type TxCircuit struct {
	TxPreImage []uints.U8 `gnark:",public"` //probably needs to provide the reversed version to save circuit space
}

func (*TxCircuit) Define

func (circuit *TxCircuit) Define(api frontend.API) error

type TxInput

type TxInput struct {
}

type TxOutput

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

type VarInt

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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