Documentation
¶
Overview ¶
Package zk provides utilities around the zkSNARK (Groth16) tooling.
Index ¶
- func BytesToArboStr(input []byte) []string
- func LittleEndianToNBytes(num *big.Int, n int) *big.Int
- func ProtobufZKProofToProverProof(p *models.ProofZkSNARK) (*prover.Proof, error)
- func ProverProofToProtobufZKProof(p *prover.Proof, electionId, censusRoot, nullifier types.HexBytes, ...) (*models.ProofZkSNARK, error)
- type ZkAddress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToArboStr ¶ added in v1.4.0
BytesToArboStr calculates the sha256 hash (32 bytes) of the slice of bytes provided. Then, splits the hash into a two parts of 16 bytes, swap the endianess of that parts, encodes they into a two big.Ints and return both as strings into a []string.
func LittleEndianToNBytes ¶ added in v1.4.0
LittleEndianToNBytes truncate the most significant n bytes of the provided little endian number provided and returns into a new big.Int.
func ProtobufZKProofToProverProof ¶ added in v1.4.0
func ProtobufZKProofToProverProof(p *models.ProofZkSNARK) (*prover.Proof, error)
ProtobufZKProofToProverProof parses the provided protobuf ready proof struct into a prover ready proof struct.
func ProverProofToProtobufZKProof ¶ added in v1.4.0
func ProverProofToProtobufZKProof(p *prover.Proof, electionId, censusRoot, nullifier types.HexBytes, weight *big.Int) (*models.ProofZkSNARK, error)
ProverProofToProtobufZKProof encodes the proof provided into a protobuf ready struct using including the index of the circuit used. If the provided proof does not contains a defined public signals, the rest of the arguments are required to calculate that parameter. If the provided proof does not contains a defined public signals and any of the rest of the parameters is nil, the resulting struct will not contains any defined PublicInputs value.
Types ¶
type ZkAddress ¶ added in v1.4.0
type ZkAddress struct { // Privkey contains the big.Int version of the BabyJubJub private key PrivKey *big.Int // PubKey contains the big.Int poseidon hash of the BabyJubJub public key // (x and y coordinates of a point of the curve) PubKey *big.Int // contains filtered or unexported fields }
ZkAddress struct allow to create and encoding properly the zk-snark compatible address for the vochain. This address is calculated from a BabyJubJub key pair, based on a seed. The address has 20 bytes of size and it is the truncated version of the poseidon hash of the BabyJubJub publicKey.
func AddressFromBytes ¶ added in v1.4.0
AddressFromBytes returns a new ZkAddress based on the seed provided. The seed has to be at least 32 bytes. Using it, a BabyJubJub key pair is calculated and based on it. The ZkAddress components are:
- ZkAddress.PrivKey: The BabyJubJub private key big.Int value, following the EdDSA standard, and using blake-512 hash.
- ZkAddress.PublicKey: The poseidon hash of the BabyJubJub public key components (X and Y coordinates as big.Int).
- ZkAddress.addr: The last 20 bytes of the ZkAddress.PublicKey. This is calculated by truncating PublicKey (a little endian number) to the defaultZkAddrLen.
func AddressFromSignKeys ¶ added in v1.4.0
AddressFromSignKeys gets the private key from the ethereum.SignKeys provided and pass its string representation as []byte to AddressFromBytes function.
func AddressFromString ¶ added in v1.4.0
AddressFromString wraps AddressFromBytes function transforming the seed from string to []byte.
func NewRandAddress ¶ added in v1.4.0
NewRandAddress returns a ZkAddress based on a random BabyJubJub private key.
func (*ZkAddress) Bytes ¶ added in v1.4.0
Bytes returns the current ZkAddress.addr transformed to types.HexBytes using the arbo.BigIntToBytes() function.
Directories
¶
Path | Synopsis |
---|---|
prover package abstracts the logic and types of go-rapidsnark (https://github.com/iden3/go-rapidsnark) to support basic operations for the rest of vocdoni-node project.
|
prover package abstracts the logic and types of go-rapidsnark (https://github.com/iden3/go-rapidsnark) to support basic operations for the rest of vocdoni-node project. |