Documentation ¶
Overview ¶
Package zsl is a generated protocol buffer package.
It is generated from these files:
zslbox.proto
It has these top-level messages:
ShieldedInput Note ShieldedTransferRequest VerifyShieldedTransferRequest ShieldedTransfer VerifyShieldingRequest Shielding VerifyUnshieldingRequest Unshielding ZAddress Bytes Result Void
Index ¶
- Constants
- func RandomBytes(length uint) []byte
- func RegisterZSLBoxServer(s *grpc.Server, srv ZSLBoxServer)
- type Bytes
- type Client
- type Hash
- type Note
- type Result
- type ShieldedInput
- func (*ShieldedInput) Descriptor() ([]byte, []int)
- func (m *ShieldedInput) GetRho() []byte
- func (m *ShieldedInput) GetSk() []byte
- func (m *ShieldedInput) GetTreeIndex() uint64
- func (m *ShieldedInput) GetTreePath() [][]byte
- func (m *ShieldedInput) GetValue() uint64
- func (*ShieldedInput) ProtoMessage()
- func (m *ShieldedInput) Reset()
- func (m *ShieldedInput) String() string
- type ShieldedTransfer
- func (*ShieldedTransfer) Descriptor() ([]byte, []int)
- func (m *ShieldedTransfer) GetCommitments() [][]byte
- func (m *ShieldedTransfer) GetSendNullifiers() [][]byte
- func (m *ShieldedTransfer) GetSnark() []byte
- func (m *ShieldedTransfer) GetSpendNullifiers() [][]byte
- func (*ShieldedTransfer) ProtoMessage()
- func (m *ShieldedTransfer) Reset()
- func (m *ShieldedTransfer) String() string
- type ShieldedTransferRequest
- func (*ShieldedTransferRequest) Descriptor() ([]byte, []int)
- func (m *ShieldedTransferRequest) GetInputs() []*ShieldedInput
- func (m *ShieldedTransferRequest) GetOutputs() []*Note
- func (*ShieldedTransferRequest) ProtoMessage()
- func (m *ShieldedTransferRequest) Reset()
- func (m *ShieldedTransferRequest) String() string
- type Shielding
- type Tree
- type Unshielding
- func (unshielding *Unshielding) DebugString() string
- func (*Unshielding) Descriptor() ([]byte, []int)
- func (m *Unshielding) GetSendNullifier() []byte
- func (m *Unshielding) GetSnark() []byte
- func (m *Unshielding) GetSpendNullifier() []byte
- func (*Unshielding) ProtoMessage()
- func (m *Unshielding) Reset()
- func (m *Unshielding) String() string
- type VerifyShieldedTransferRequest
- func (*VerifyShieldedTransferRequest) Descriptor() ([]byte, []int)
- func (m *VerifyShieldedTransferRequest) GetShieldedTransfer() *ShieldedTransfer
- func (m *VerifyShieldedTransferRequest) GetTreeRoot() []byte
- func (*VerifyShieldedTransferRequest) ProtoMessage()
- func (m *VerifyShieldedTransferRequest) Reset()
- func (m *VerifyShieldedTransferRequest) String() string
- type VerifyShieldingRequest
- func (*VerifyShieldingRequest) Descriptor() ([]byte, []int)
- func (m *VerifyShieldingRequest) GetShielding() *Shielding
- func (m *VerifyShieldingRequest) GetValue() uint64
- func (*VerifyShieldingRequest) ProtoMessage()
- func (m *VerifyShieldingRequest) Reset()
- func (m *VerifyShieldingRequest) String() string
- type VerifyUnshieldingRequest
- func (*VerifyUnshieldingRequest) Descriptor() ([]byte, []int)
- func (m *VerifyUnshieldingRequest) GetSnark() []byte
- func (m *VerifyUnshieldingRequest) GetSpendNullifier() []byte
- func (m *VerifyUnshieldingRequest) GetTreeRoot() []byte
- func (m *VerifyUnshieldingRequest) GetValue() uint64
- func (*VerifyUnshieldingRequest) ProtoMessage()
- func (m *VerifyUnshieldingRequest) Reset()
- func (m *VerifyUnshieldingRequest) String() string
- type Void
- type ZAddress
- type ZSLBoxClient
- type ZSLBoxServer
Constants ¶
const ( HashSize = 32 TreeDepth = 29 ProofSize = 584 )
Variables ¶
This section is empty.
Functions ¶
func RandomBytes ¶
RandomBytes returns a []byte filled with random bytes
func RegisterZSLBoxServer ¶
func RegisterZSLBoxServer(s *grpc.Server, srv ZSLBoxServer)
Types ¶
type Bytes ¶
type Bytes struct {
Bytes []byte `protobuf:"bytes,1,opt,name=bytes,proto3" json:"bytes,omitempty"`
}
func (*Bytes) Descriptor ¶
func (*Bytes) ProtoMessage ¶
func (*Bytes) ProtoMessage()
type Client ¶
type Client struct { ZSLBox ZSLBoxClient // contains filtered or unexported fields }
Client connects to a ZSLBox gRPC server
type Note ¶
type Note struct { Pk []byte `protobuf:"bytes,1,opt,name=pk,proto3" json:"pk,omitempty"` Rho []byte `protobuf:"bytes,2,opt,name=rho,proto3" json:"rho,omitempty"` Value uint64 `protobuf:"varint,3,opt,name=value" json:"value,omitempty"` }
func (*Note) Descriptor ¶
func (*Note) ProtoMessage ¶
func (*Note) ProtoMessage()
type Result ¶
type Result struct { Result bool `protobuf:"varint,1,opt,name=result" json:"result,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` }
func (*Result) Descriptor ¶
func (*Result) GetMessage ¶
func (*Result) ProtoMessage ¶
func (*Result) ProtoMessage()
type ShieldedInput ¶
type ShieldedInput struct { Sk []byte `protobuf:"bytes,1,opt,name=sk,proto3" json:"sk,omitempty"` Rho []byte `protobuf:"bytes,2,opt,name=rho,proto3" json:"rho,omitempty"` Value uint64 `protobuf:"varint,3,opt,name=value" json:"value,omitempty"` TreeIndex uint64 `protobuf:"varint,4,opt,name=treeIndex" json:"treeIndex,omitempty"` TreePath [][]byte `protobuf:"bytes,5,rep,name=treePath,proto3" json:"treePath,omitempty"` }
------------------------------------------------------------------------------------------------- Cross operation data structs
func (*ShieldedInput) Descriptor ¶
func (*ShieldedInput) Descriptor() ([]byte, []int)
func (*ShieldedInput) GetRho ¶
func (m *ShieldedInput) GetRho() []byte
func (*ShieldedInput) GetSk ¶
func (m *ShieldedInput) GetSk() []byte
func (*ShieldedInput) GetTreeIndex ¶
func (m *ShieldedInput) GetTreeIndex() uint64
func (*ShieldedInput) GetTreePath ¶
func (m *ShieldedInput) GetTreePath() [][]byte
func (*ShieldedInput) GetValue ¶
func (m *ShieldedInput) GetValue() uint64
func (*ShieldedInput) ProtoMessage ¶
func (*ShieldedInput) ProtoMessage()
func (*ShieldedInput) Reset ¶
func (m *ShieldedInput) Reset()
func (*ShieldedInput) String ¶
func (m *ShieldedInput) String() string
type ShieldedTransfer ¶
type ShieldedTransfer struct { Snark []byte `protobuf:"bytes,1,opt,name=snark,proto3" json:"snark,omitempty"` // input spend nullifiers SpendNullifiers [][]byte `protobuf:"bytes,2,rep,name=spendNullifiers,proto3" json:"spendNullifiers,omitempty"` // output send nullifiers & commitments SendNullifiers [][]byte `protobuf:"bytes,3,rep,name=sendNullifiers,proto3" json:"sendNullifiers,omitempty"` Commitments [][]byte `protobuf:"bytes,4,rep,name=commitments,proto3" json:"commitments,omitempty"` }
func NewShieldedTransfer ¶ added in v0.2.1
func NewShieldedTransfer() *ShieldedTransfer
func (*ShieldedTransfer) Descriptor ¶
func (*ShieldedTransfer) Descriptor() ([]byte, []int)
func (*ShieldedTransfer) GetCommitments ¶
func (m *ShieldedTransfer) GetCommitments() [][]byte
func (*ShieldedTransfer) GetSendNullifiers ¶
func (m *ShieldedTransfer) GetSendNullifiers() [][]byte
func (*ShieldedTransfer) GetSnark ¶
func (m *ShieldedTransfer) GetSnark() []byte
func (*ShieldedTransfer) GetSpendNullifiers ¶
func (m *ShieldedTransfer) GetSpendNullifiers() [][]byte
func (*ShieldedTransfer) ProtoMessage ¶
func (*ShieldedTransfer) ProtoMessage()
func (*ShieldedTransfer) Reset ¶
func (m *ShieldedTransfer) Reset()
func (*ShieldedTransfer) String ¶
func (m *ShieldedTransfer) String() string
type ShieldedTransferRequest ¶
type ShieldedTransferRequest struct { Inputs []*ShieldedInput `protobuf:"bytes,1,rep,name=inputs" json:"inputs,omitempty"` Outputs []*Note `protobuf:"bytes,2,rep,name=outputs" json:"outputs,omitempty"` }
------------------------------------------------------------------------------------------------- ShieldedTransfer data structs note: a shielded transfer has 2 inputs and 2 outputs (UTXO model)
func (*ShieldedTransferRequest) Descriptor ¶
func (*ShieldedTransferRequest) Descriptor() ([]byte, []int)
func (*ShieldedTransferRequest) GetInputs ¶
func (m *ShieldedTransferRequest) GetInputs() []*ShieldedInput
func (*ShieldedTransferRequest) GetOutputs ¶
func (m *ShieldedTransferRequest) GetOutputs() []*Note
func (*ShieldedTransferRequest) ProtoMessage ¶
func (*ShieldedTransferRequest) ProtoMessage()
func (*ShieldedTransferRequest) Reset ¶
func (m *ShieldedTransferRequest) Reset()
func (*ShieldedTransferRequest) String ¶
func (m *ShieldedTransferRequest) String() string
type Shielding ¶
type Shielding struct { Snark []byte `protobuf:"bytes,1,opt,name=snark,proto3" json:"snark,omitempty"` Commitment []byte `protobuf:"bytes,2,opt,name=commitment,proto3" json:"commitment,omitempty"` SendNullifier []byte `protobuf:"bytes,3,opt,name=sendNullifier,proto3" json:"sendNullifier,omitempty"` }
func NewShielding ¶ added in v0.2.1
func NewShielding() *Shielding
func (*Shielding) Descriptor ¶
func (*Shielding) GetCommitment ¶
func (*Shielding) GetSendNullifier ¶
func (*Shielding) ProtoMessage ¶
func (*Shielding) ProtoMessage()
type Tree ¶
type Tree struct { EmptyRootsByHeight []Hash // contains filtered or unexported fields }
Tree is an incremental Merkle Tree of fixed depth as described in ZCash protocol It is rudimentary and for testing purposes only (needs optimization)
func (*Tree) AddCommitment ¶
AddCommitment adds a commitment to the tree, and return its index
func (*Tree) GetWitnesses ¶
GetWitnesses return treeIndex and authPath from leaf to root
type Unshielding ¶
type Unshielding struct { Snark []byte `protobuf:"bytes,1,opt,name=snark,proto3" json:"snark,omitempty"` SpendNullifier []byte `protobuf:"bytes,2,opt,name=spendNullifier,proto3" json:"spendNullifier,omitempty"` SendNullifier []byte `protobuf:"bytes,3,opt,name=sendNullifier,proto3" json:"sendNullifier,omitempty"` }
func (*Unshielding) DebugString ¶ added in v0.2.1
func (unshielding *Unshielding) DebugString() string
func (*Unshielding) Descriptor ¶
func (*Unshielding) Descriptor() ([]byte, []int)
func (*Unshielding) GetSendNullifier ¶
func (m *Unshielding) GetSendNullifier() []byte
func (*Unshielding) GetSnark ¶
func (m *Unshielding) GetSnark() []byte
func (*Unshielding) GetSpendNullifier ¶
func (m *Unshielding) GetSpendNullifier() []byte
func (*Unshielding) ProtoMessage ¶
func (*Unshielding) ProtoMessage()
func (*Unshielding) Reset ¶
func (m *Unshielding) Reset()
func (*Unshielding) String ¶
func (m *Unshielding) String() string
type VerifyShieldedTransferRequest ¶
type VerifyShieldedTransferRequest struct { ShieldedTransfer *ShieldedTransfer `protobuf:"bytes,1,opt,name=shieldedTransfer" json:"shieldedTransfer,omitempty"` TreeRoot []byte `protobuf:"bytes,2,opt,name=treeRoot,proto3" json:"treeRoot,omitempty"` }
func NewVerifyShieldedTransferRequest ¶ added in v0.2.1
func NewVerifyShieldedTransferRequest() *VerifyShieldedTransferRequest
func (*VerifyShieldedTransferRequest) Descriptor ¶
func (*VerifyShieldedTransferRequest) Descriptor() ([]byte, []int)
func (*VerifyShieldedTransferRequest) GetShieldedTransfer ¶
func (m *VerifyShieldedTransferRequest) GetShieldedTransfer() *ShieldedTransfer
func (*VerifyShieldedTransferRequest) GetTreeRoot ¶
func (m *VerifyShieldedTransferRequest) GetTreeRoot() []byte
func (*VerifyShieldedTransferRequest) ProtoMessage ¶
func (*VerifyShieldedTransferRequest) ProtoMessage()
func (*VerifyShieldedTransferRequest) Reset ¶
func (m *VerifyShieldedTransferRequest) Reset()
func (*VerifyShieldedTransferRequest) String ¶
func (m *VerifyShieldedTransferRequest) String() string
type VerifyShieldingRequest ¶
type VerifyShieldingRequest struct { Shielding *Shielding `protobuf:"bytes,1,opt,name=shielding" json:"shielding,omitempty"` Value uint64 `protobuf:"varint,2,opt,name=value" json:"value,omitempty"` }
------------------------------------------------------------------------------------------------- Shielding data structs
func NewVerifyShieldingRequest ¶ added in v0.2.1
func NewVerifyShieldingRequest() *VerifyShieldingRequest
func (*VerifyShieldingRequest) Descriptor ¶
func (*VerifyShieldingRequest) Descriptor() ([]byte, []int)
func (*VerifyShieldingRequest) GetShielding ¶
func (m *VerifyShieldingRequest) GetShielding() *Shielding
func (*VerifyShieldingRequest) GetValue ¶
func (m *VerifyShieldingRequest) GetValue() uint64
func (*VerifyShieldingRequest) ProtoMessage ¶
func (*VerifyShieldingRequest) ProtoMessage()
func (*VerifyShieldingRequest) Reset ¶
func (m *VerifyShieldingRequest) Reset()
func (*VerifyShieldingRequest) String ¶
func (m *VerifyShieldingRequest) String() string
type VerifyUnshieldingRequest ¶
type VerifyUnshieldingRequest struct { Snark []byte `protobuf:"bytes,1,opt,name=snark,proto3" json:"snark,omitempty"` SpendNullifier []byte `protobuf:"bytes,2,opt,name=spendNullifier,proto3" json:"spendNullifier,omitempty"` TreeRoot []byte `protobuf:"bytes,3,opt,name=treeRoot,proto3" json:"treeRoot,omitempty"` Value uint64 `protobuf:"varint,4,opt,name=value" json:"value,omitempty"` }
------------------------------------------------------------------------------------------------- Unshielding data structs
func NewVerifyUnshieldingRequest ¶ added in v0.2.1
func NewVerifyUnshieldingRequest() *VerifyUnshieldingRequest
func (*VerifyUnshieldingRequest) Descriptor ¶
func (*VerifyUnshieldingRequest) Descriptor() ([]byte, []int)
func (*VerifyUnshieldingRequest) GetSnark ¶
func (m *VerifyUnshieldingRequest) GetSnark() []byte
func (*VerifyUnshieldingRequest) GetSpendNullifier ¶
func (m *VerifyUnshieldingRequest) GetSpendNullifier() []byte
func (*VerifyUnshieldingRequest) GetTreeRoot ¶
func (m *VerifyUnshieldingRequest) GetTreeRoot() []byte
func (*VerifyUnshieldingRequest) GetValue ¶
func (m *VerifyUnshieldingRequest) GetValue() uint64
func (*VerifyUnshieldingRequest) ProtoMessage ¶
func (*VerifyUnshieldingRequest) ProtoMessage()
func (*VerifyUnshieldingRequest) Reset ¶
func (m *VerifyUnshieldingRequest) Reset()
func (*VerifyUnshieldingRequest) String ¶
func (m *VerifyUnshieldingRequest) String() string
type Void ¶
type Void struct { }
func (*Void) Descriptor ¶
func (*Void) ProtoMessage ¶
func (*Void) ProtoMessage()
type ZAddress ¶
type ZAddress struct { Sk []byte `protobuf:"bytes,1,opt,name=sk,proto3" json:"sk,omitempty"` Pk []byte `protobuf:"bytes,2,opt,name=pk,proto3" json:"pk,omitempty"` }
------------------------------------------------------------------------------------------------- Other
func (*ZAddress) Descriptor ¶
func (*ZAddress) ProtoMessage ¶
func (*ZAddress) ProtoMessage()
type ZSLBoxClient ¶
type ZSLBoxClient interface { // CreateShielding computes a zkSNARK and a note commitment for given note. // Also returns a sendNullifier to ensure note.Rho (random) is unique CreateShielding(ctx context.Context, in *Note, opts ...grpc.CallOption) (*Shielding, error) // CreateUnshielding computes a zkSNARK, nullifiers for given input, using Unshielding circuit CreateUnshielding(ctx context.Context, in *ShieldedInput, opts ...grpc.CallOption) (*Unshielding, error) // CreateShieldedTransfer takes 2 notes as inputs (known Sk) and 2 desired output notes. // It returns the zkSNARK, the spend nullifiers for the inputs, and the commitments & send nullifiers for outputs CreateShieldedTransfer(ctx context.Context, in *ShieldedTransferRequest, opts ...grpc.CallOption) (*ShieldedTransfer, error) // VerifyShielding ensures that the provided Shielding proof is valid. It takes as input the zkSNARK, // the send nullifier, commitment and value of the shielded note. VerifyShielding(ctx context.Context, in *VerifyShieldingRequest, opts ...grpc.CallOption) (*Result, error) // VerifyUnshielding ensures that the provided Unshielding proof is valid. It takes as input the zkSNARK, // the spend nullifier, the tree root and value of the shielded note. VerifyUnshielding(ctx context.Context, in *VerifyUnshieldingRequest, opts ...grpc.CallOption) (*Result, error) // VerifyShieldedTransfer ensures that the provided shielded transfer proof is valid. // It takes as input the zkSNARK, treeRoot, spend nullifiers for inputs and send nullifiers & commitments // for outputs VerifyShieldedTransfer(ctx context.Context, in *VerifyShieldedTransferRequest, opts ...grpc.CallOption) (*Result, error) // GetCommitment returns SHA256(note.Rho || note.Pk || note.Value) // where note.Value is in little endian byte order GetCommitment(ctx context.Context, in *Note, opts ...grpc.CallOption) (*Bytes, error) // GetSendNullifier returns SHA256(0x00 || note.Rho) GetSendNullifier(ctx context.Context, in *Note, opts ...grpc.CallOption) (*Bytes, error) // GetSpendNullifier returns SHA256(0x01 || shieldedInput.Rho || shieldedInput.Sk) GetSpendNullifier(ctx context.Context, in *ShieldedInput, opts ...grpc.CallOption) (*Bytes, error) // GetNewAddress returns a tuple (Pk, Sk) where Pk is the paying (public) key and Sk is the secret key GetNewAddress(ctx context.Context, in *Void, opts ...grpc.CallOption) (*ZAddress, error) // Sha256Compress applies SHA-256 to one input block, excluding the padding step specified in [NIST2015, Section 5.1] Sha256Compress(ctx context.Context, in *Bytes, opts ...grpc.CallOption) (*Bytes, error) }
func NewZSLBoxClient ¶
func NewZSLBoxClient(cc *grpc.ClientConn) ZSLBoxClient
type ZSLBoxServer ¶
type ZSLBoxServer interface { // CreateShielding computes a zkSNARK and a note commitment for given note. // Also returns a sendNullifier to ensure note.Rho (random) is unique CreateShielding(context.Context, *Note) (*Shielding, error) // CreateUnshielding computes a zkSNARK, nullifiers for given input, using Unshielding circuit CreateUnshielding(context.Context, *ShieldedInput) (*Unshielding, error) // CreateShieldedTransfer takes 2 notes as inputs (known Sk) and 2 desired output notes. // It returns the zkSNARK, the spend nullifiers for the inputs, and the commitments & send nullifiers for outputs CreateShieldedTransfer(context.Context, *ShieldedTransferRequest) (*ShieldedTransfer, error) // VerifyShielding ensures that the provided Shielding proof is valid. It takes as input the zkSNARK, // the send nullifier, commitment and value of the shielded note. VerifyShielding(context.Context, *VerifyShieldingRequest) (*Result, error) // VerifyUnshielding ensures that the provided Unshielding proof is valid. It takes as input the zkSNARK, // the spend nullifier, the tree root and value of the shielded note. VerifyUnshielding(context.Context, *VerifyUnshieldingRequest) (*Result, error) // VerifyShieldedTransfer ensures that the provided shielded transfer proof is valid. // It takes as input the zkSNARK, treeRoot, spend nullifiers for inputs and send nullifiers & commitments // for outputs VerifyShieldedTransfer(context.Context, *VerifyShieldedTransferRequest) (*Result, error) // GetCommitment returns SHA256(note.Rho || note.Pk || note.Value) // where note.Value is in little endian byte order GetCommitment(context.Context, *Note) (*Bytes, error) // GetSendNullifier returns SHA256(0x00 || note.Rho) GetSendNullifier(context.Context, *Note) (*Bytes, error) // GetSpendNullifier returns SHA256(0x01 || shieldedInput.Rho || shieldedInput.Sk) GetSpendNullifier(context.Context, *ShieldedInput) (*Bytes, error) // GetNewAddress returns a tuple (Pk, Sk) where Pk is the paying (public) key and Sk is the secret key GetNewAddress(context.Context, *Void) (*ZAddress, error) // Sha256Compress applies SHA-256 to one input block, excluding the padding step specified in [NIST2015, Section 5.1] Sha256Compress(context.Context, *Bytes) (*Bytes, error) }