witness

package
Version: v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package witness provides serialization helpers to encode a witness into a []byte.

Binary protocol

Full witness     ->  [uint32(nbElements) | publicVariables | secretVariables]
Public witness   ->  [uint32(nbElements) | publicVariables ]

where

* `nbElements == len(publicVariables) + len(secretVariables)`.
* each variable (a *field element*) is encoded as a big-endian byte array, where `len(bytes(variable)) == len(bytes(modulus))`

Ordering

First, `publicVariables`, then `secretVariables`. Each subset is ordered from the order of definition in the circuit structure. For example, with this circuit on `ecc.BN254`

type Circuit struct {
    X frontend.Variable
    Y frontend.Variable `gnark:",public"`
    Z frontend.Variable
}

A valid witness would be:

* `[uint32(3)|bytes(Y)|bytes(X)|bytes(Z)]`
* Hex representation with values `Y = 35`, `X = 3`, `Z = 2`
`00000003000000000000000000000000000000000000000000000000000000000000002300000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFullTo

func WriteFullTo(w io.Writer, curveID ecc.ID, witness frontend.Circuit) (int64, error)

WriteFullTo encodes the witness to a slice of []fr.Element and write the []byte on provided writer

func WritePublicTo

func WritePublicTo(w io.Writer, curveID ecc.ID, publicWitness frontend.Circuit) (int64, error)

WritePublicTo encodes the witness to a slice of []fr.Element and write the result on provided writer

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL