Documentation
¶
Index ¶
- Constants
- func G1ToBigInts(g1 *bn256.G1) [2]*big.Int
- func G2ToBigInts(g2 *bn256.G2) [2][2]*big.Int
- func InputsToMapStrings(inputs interface{}) (map[string]interface{}, error)
- func PrintProof(proof *zktypes.Proof)
- func ProofToBigInts(proof *zktypes.Proof) (a [2]*big.Int, b [2][2]*big.Int, c [2]*big.Int)
- type ProvingKeyFormat
- type PubSignals
- type ZkFiles
- func (z *ZkFiles) DebugDownloadPrintHashes(provingKeyFormat ProvingKeyFormat) error
- func (z *ZkFiles) DownloadAll() error
- func (z *ZkFiles) DownloadProvingKey() error
- func (z *ZkFiles) DownloadVerificationKey() error
- func (z *ZkFiles) DownloadWitnessCalcWASM() error
- func (z *ZkFiles) InsecureCalcHashes() (*ZkFilesHashes, error)
- func (z *ZkFiles) InsecureDownloadAll() error
- func (z *ZkFiles) LoadAll() error
- func (z *ZkFiles) LoadProvingKey() error
- func (z *ZkFiles) LoadVerificationKey() error
- func (z *ZkFiles) LoadWitnessCalcWASM() error
- func (z *ZkFiles) ProvingKey() (*zktypes.Pk, error)
- func (z *ZkFiles) VerificationKey() (*zktypes.Vk, error)
- func (z *ZkFiles) WitnessCalcWASM() ([]byte, error)
- type ZkFilesBasename
- type ZkFilesHashes
- type ZkProofOut
Constants ¶
const ( ProvingKeyFormatJSON = "json" ProvingKeyFormatBin = "bin" ProvingKeyFormatGoBin = "go.bin" )
Variables ¶
This section is empty.
Functions ¶
func G1ToBigInts ¶
G1ToBigInts transforms a `*bn256.G1` into `*big.Int` format, to be used for example in snarkjs solidity verifiers.
func G2ToBigInts ¶
G2ToBigInts transforms a `*bn256.G2` into `*big.Int` format, to be used for example in snarkjs solidity verifiers.
func InputsToMapStrings ¶
InputsToMapStrings transforms the input signals map from *big.Int type (as used in witnesscalc) to quoted strings (as used in JSON encoding).
func PrintProof ¶
PrintProof prints the zkp in JSON pretty format.
Types ¶
type ProvingKeyFormat ¶
type ProvingKeyFormat string
type PubSignals ¶
PubSignals is a helper wrapper type over []*big.Int that is JSON friendly.
func (PubSignals) MarshalJSON ¶
func (p PubSignals) MarshalJSON() ([]byte, error)
func (*PubSignals) UnmarshalJSON ¶
func (p *PubSignals) UnmarshalJSON(data []byte) error
type ZkFiles ¶
ZkFiles allows convenient access to the files required for zk proving and verifying.
func NewZkFiles ¶
func NewZkFiles(url, path string, provingKeyFormat ProvingKeyFormat, hashes ZkFilesHashes, cacheProvingKey bool) *ZkFiles
NewZkFiles creates a new ZkFiles that will try to use the zk files from `path` checking that the `hashes` match with the files. If the files don't exist, they are downloaded into `path` from `url`. The proving key can be quite big: setting `cacheProvingKey` to false will make the ZkFiles not keep it in memory after requesting it, parsing it from disk every time it is required. The rest of the files are always cached.
func (*ZkFiles) DebugDownloadPrintHashes ¶
func (z *ZkFiles) DebugDownloadPrintHashes(provingKeyFormat ProvingKeyFormat) error
DebugDownloadPrintHashes is a helper function that downloads all the zk files in a temporary directory, calculates their hashes, and prints the code of the `ZkFilesHashes` with the calculated hashes, ready to be pasted in real code.
func (*ZkFiles) DownloadAll ¶
DownloadAll downloads all the zk files and checks their hashes.
func (*ZkFiles) DownloadProvingKey ¶
DownloadProvingKey downloads the ProvingKey and checks its hash.
func (*ZkFiles) DownloadVerificationKey ¶
DownloadVerificationKey downloads the VerificationKey and checks its hash.
func (*ZkFiles) DownloadWitnessCalcWASM ¶
DownloadWitnessCalcWASM downloads the WitnessCalcWASM and checks its hash.
func (*ZkFiles) InsecureCalcHashes ¶
func (z *ZkFiles) InsecureCalcHashes() (*ZkFilesHashes, error)
InsecureCalcHashes calculates the hashes of the zkfiles without checking them.
func (*ZkFiles) InsecureDownloadAll ¶
InsecureDownloadAll downloads all the zk files but doesn't check the hashes.
func (*ZkFiles) LoadProvingKey ¶
LoadProvingKey loads the ProvingKey, downloading it if necessary.
func (*ZkFiles) LoadVerificationKey ¶
LoadVerificationKey loads the VerificationKey, downloading it if necessary.
func (*ZkFiles) LoadWitnessCalcWASM ¶
LoadWitnessCalcWASM loads the WitnessCalcWASM, downloading it if necessary.
func (*ZkFiles) ProvingKey ¶
ProvingKey returns the ProvingKey, downloading and loading it if necessary.
func (*ZkFiles) VerificationKey ¶
VerificationKey returns the VerificationKey, downloading and loading it if necessary.
func (*ZkFiles) WitnessCalcWASM ¶
WitnessCalcWASM returns the WitnessCalcWASM byte slice, downloading and loading it if necessary.
type ZkFilesBasename ¶
type ZkFilesHashes ¶
ZkFilesHashes are the sha256 hash in hex of the zk files