Documentation
¶
Overview ¶
Package phase2 implements functions interacting with multi-party computation Phase 2 objects produced by Gnark.
Index ¶
- func Contribute(inputPhase2FilePath, outputPhase2FilePath string) error
- func ExtractKeys(r1csFilePath, srsCommonsFilePath string, phase2FilePaths []string, ...) error
- func FromFile(phase2Path string) (phase2 *mpcsetup.Phase2, err error)
- func Init(...) error
- func PkVkFromFile(pkFilePath string, vkFilePath string) (groth16.ProvingKey, groth16.VerifyingKey, error)
- func PkVkToFile(pk groth16.ProvingKey, pkFilePath string, vk groth16.VerifyingKey, ...) error
- func SrsCommonsFromFile(srsCommonsPath string) (srsCommons *mpcsetup.SrsCommons, err error)
- func SrsCommonsToFile(srsCommons *mpcsetup.SrsCommons, srsCommonsPath string) error
- func ToFile(phase2 *mpcsetup.Phase2, phase2Path string) error
- func Verify(phase2prevFilePath, phase2nextFilePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contribute ¶
Contribute contributes randomness to the given Phase 2 object.
The Phase 2 object is deserialized from the file specified by inputPhase2FilePath. The randomness is contributed to the Phase 2 object, and the updated object is written outputPhase2FilePath. The input file is not modified.
func ExtractKeys ¶
func ExtractKeys( r1csFilePath, srsCommonsFilePath string, phase2FilePaths []string, outputPkFilePath, outputVkFilePath string, beacon []byte, ) error
ExtractKeys verifies the given Phase 2 objects for the correctness of their contributions and extracts the proving and verification keys.
The Phase 2 objects are deserialized from the files specified by phase2FilePaths. The verification is performed between each consecutive pair of Phase 2 objects that contain contributions (that is EXCLUDING the initial one). The verification is performed in the order of the input files.
The constraint system used for Phase 2 initialization and the SRS Commons object being the result if the initialization must be provided in the form of file paths.
The random value needed to extract keys from contributions is given as beacon. It must be the same value passed to Init when generating SRS that is now being passed to ExtractKeys as srsCommonsFilePath.
The output proving key is written to outputPkFilePath. The output verification key is written to outputVkFilePath.
Returns nil on success and error on failure.
func FromFile ¶
FromFile reads the Phase 2 object from the file specified by phase2Path and returns the Phase 2 object.
Returns the Phase 2 object and nil on success and nil and error on failure.
func Init ¶
func Init( phase1FilePath, r1csFilePath, outputPhase2FilePath, outputSrsCommonsPath string, beacon []byte, ) error
Init initializes the multi-party computation Phase 2 object based on a serialized Phase 1 and R1CS objects.
The input serialized Phase 1 object is given as phase1FilePath. The input serialized R1CS object is given as r1csFilePath. The random value needed to generate SRS commons is given as beacon.
The output Phase 2 object is written to outputPhase2FilePath, and the SRS commons file is written to outputSrsCommonsPath.
Returns nil on success and error on failure.
func PkVkFromFile ¶
func PkVkFromFile(pkFilePath string, vkFilePath string) (groth16.ProvingKey, groth16.VerifyingKey, error)
PkVkFromFile reads the proving and verification keys from the files specified by pkFilePath and vkFilePath.
Returns the proving and verification keys and nil on success and empty keys and error on failure.
func PkVkToFile ¶
func PkVkToFile( pk groth16.ProvingKey, pkFilePath string, vk groth16.VerifyingKey, vkFilePath string, ) error
PkVkToFile writes the proving and verification keys to the files specified by pkFilePath and vkFilePath.
Returns nil on success and error on failure.
func SrsCommonsFromFile ¶
func SrsCommonsFromFile(srsCommonsPath string) (srsCommons *mpcsetup.SrsCommons, err error)
SrsCommonsFromFile reads the circuit-independent components of the Groth16 SRS from the file specified by srsCommonsPath and returns the SrsCommons object.
Returns the SrsCommons object and nil on success and nil and error on failure.
func SrsCommonsToFile ¶
func SrsCommonsToFile(srsCommons *mpcsetup.SrsCommons, srsCommonsPath string) error
SrsCommonsToFile writes circuit-independent components of the Groth16 SRS provided by srsCommons to a file specified by srsCommonsPath.
Returns nil on success and error on failure.
func ToFile ¶
ToFile writes the Phase 2 object provided in phase2 to a file specified by phase2Path.
Returns nil on success and error on failure.
func Verify ¶
Verify verifies the given Phase 2 objects for the correctness of their contributions.
The Phase 2 objects are deserialized from the files specified by phase2prevFilePath and phase2nextFilePath. phase2prevFilePath is a file that was an input to a contribution, and phase2nextFilePath is the output of that contribution.
Returns nil on success and error on failure.
Types ¶
This section is empty.