zsl

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: Apache-2.0 Imports: 11 Imported by: 1

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

View Source
const (
	HashSize  = 32
	TreeDepth = 29
	ProofSize = 584
)

Variables

This section is empty.

Functions

func RandomBytes

func RandomBytes(length uint) []byte

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) Descriptor() ([]byte, []int)

func (*Bytes) GetBytes

func (m *Bytes) GetBytes() []byte

func (*Bytes) ProtoMessage

func (*Bytes) ProtoMessage()

func (*Bytes) Reset

func (m *Bytes) Reset()

func (*Bytes) String

func (m *Bytes) String() string

type Client

type Client struct {
	ZSLBox ZSLBoxClient
	// contains filtered or unexported fields
}

Client connects to a ZSLBox gRPC server

func NewClient

func NewClient(serverAddr string) (*Client, error)

NewClient connects to a gRPC endpoint (ZSLBox) and return the gRPC connection and ZSLBox service

func (*Client) Close

func (c *Client) Close()

Close should be call to release the connection

func (*Client) Context

func (c *Client) Context() context.Context

Context returns a golang.org/x/net/context. TODO: add authentication metadata

type Hash

type Hash = [HashSize]byte

Hash is a type alias on a 32 byte array for clarity

func NewHash

func NewHash(from []byte) Hash

NewHash returns a 32 byte array from a byte slice

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) Descriptor() ([]byte, []int)

func (*Note) GetPk

func (m *Note) GetPk() []byte

func (*Note) GetRho

func (m *Note) GetRho() []byte

func (*Note) GetValue

func (m *Note) GetValue() uint64

func (*Note) ProtoMessage

func (*Note) ProtoMessage()

func (*Note) Reset

func (m *Note) Reset()

func (*Note) String

func (m *Note) String() string

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) Descriptor() ([]byte, []int)

func (*Result) GetMessage

func (m *Result) GetMessage() string

func (*Result) GetResult

func (m *Result) GetResult() bool

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) Reset

func (m *Result) Reset()

func (*Result) String

func (m *Result) String() string

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) Descriptor() ([]byte, []int)

func (*Shielding) GetCommitment

func (m *Shielding) GetCommitment() []byte

func (*Shielding) GetSendNullifier

func (m *Shielding) GetSendNullifier() []byte

func (*Shielding) GetSnark

func (m *Shielding) GetSnark() []byte

func (*Shielding) ProtoMessage

func (*Shielding) ProtoMessage()

func (*Shielding) Reset

func (m *Shielding) Reset()

func (*Shielding) String

func (m *Shielding) String() string

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 NewTree

func NewTree(depth uint) *Tree

NewTree returns a new Merkle Tree of fixed depth depth

func (*Tree) AddCommitment

func (tree *Tree) AddCommitment(commitment Hash) (uint, error)

AddCommitment adds a commitment to the tree, and return its index

func (*Tree) GetWitnesses

func (tree *Tree) GetWitnesses(commitment Hash) (uint, [][]byte, error)

GetWitnesses return treeIndex and authPath from leaf to root

func (*Tree) Root

func (tree *Tree) Root() Hash

Root computes and return the tree root value

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

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) Descriptor() ([]byte, []int)

func (*Void) ProtoMessage

func (*Void) ProtoMessage()

func (*Void) Reset

func (m *Void) Reset()

func (*Void) String

func (m *Void) String() string

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) Descriptor() ([]byte, []int)

func (*ZAddress) GetPk

func (m *ZAddress) GetPk() []byte

func (*ZAddress) GetSk

func (m *ZAddress) GetSk() []byte

func (*ZAddress) ProtoMessage

func (*ZAddress) ProtoMessage()

func (*ZAddress) Reset

func (m *ZAddress) Reset()

func (*ZAddress) String

func (m *ZAddress) String() string

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL