avtc

package module
v0.0.0-...-445c615 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

AVTC

Attribute Verifiable Timed Commitment

This repository consists of the ZK-SNARK implementation of AVTC in Go.

Documentation

Index

Constants

View Source
const (
	Layers      = 98
	WordSize    = 120
	ModulusSize = 2048
	Words       = (ModulusSize+ModulusSize)/WordSize + 2
)

Variables

View Source
var (
	N    *big.Int
	Base *big.Int
)

Functions

func AssertSHA256

func AssertSHA256(api frontend.API, c *Circuit) error

func Compose

func Compose(in BaseDec, base *big.Int) *big.Int

func RandomGroupElement

func RandomGroupElement() *big.Int

func RunBenchmark

func RunBenchmark()

func SquareModExtractLSBPlaintext

func SquareModExtractLSBPlaintext(maxDepth int, in *big.Int, base *big.Int) ([]LayerPrecomputedValues, InputOutput)

Types

type BaseDec

type BaseDec []*big.Int

func Decompose

func Decompose(n *big.Int, base *big.Int) BaseDec

func XPlusY

func XPlusY(X BaseDec, Y BaseDec, base *big.Int) BaseDec

func XmulY

func XmulY(X BaseDec, Y BaseDec, base *big.Int) (BaseDec, []*big.Int, []*big.Int)

func (BaseDec) ToVariable

func (bd BaseDec) ToVariable(words int) []frontend.Variable

type Circuit

type Circuit struct {
	N        []frontend.Variable `gnark:",public"`
	U        []frontend.Variable `gnark:",public"`
	In       []frontend.Variable
	As       [Layers][]frontend.Variable
	Bs       [Layers][]frontend.Variable
	LSBHints [Layers - 2]frontend.Variable
	Ts       [Layers][]frontend.Variable
	TNs      [Layers][]frontend.Variable
	Hints    [Layers][]frontend.Variable
	Carries  [Layers][]frontend.Variable
	Hints2   [Layers][]frontend.Variable
	Carries2 [Layers][]frontend.Variable
	LSBs     [Layers - 2]frontend.Variable

	// SHA256
	Hash      [8][32]frontend.Variable  `gnark:",public"`
	Constants [8][32]frontend.Variable  `gnark:",public"`
	K         [64][32]frontend.Variable `gnark:",public"`
	Data      [16][32]frontend.Variable
	State     [8][32]frontend.Variable
}

func (*Circuit) Define

func (c *Circuit) Define(api frontend.API) error

type InputOutput

type InputOutput struct {
	N        BaseDec
	U        BaseDec
	In       BaseDec
	PreImage []byte
	Hash     []byte
}

type LayerPrecomputedValues

type LayerPrecomputedValues struct {
	T        BaseDec
	B        BaseDec
	A        BaseDec
	TN       BaseDec
	Hints    BaseDec
	Carries  BaseDec
	Hints2   BaseDec
	Carries2 BaseDec
	LSB      *big.Int
}

type SHA256Witness

type SHA256Witness struct {
	Hash      [8][32]frontend.Variable  `gnark:",public"`
	Constants [8][32]frontend.Variable  `gnark:",public"`
	K         [64][32]frontend.Variable `gnark:",public"`
	Data      [16][32]frontend.Variable
	State     [8][32]frontend.Variable
}

func PrepareSHA256Witness

func PrepareSHA256Witness(preImage []byte, hash []byte) SHA256Witness

Jump to

Keyboard shortcuts

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