add NU5 Orchard transaction data to CompactBlock

This commit is contained in:
Larry Ruane 2021-11-30 10:08:21 -07:00 committed by Larry Ruane
parent fdc54babf2
commit 4e1910aeea
6 changed files with 255 additions and 84 deletions

View File

@ -137,11 +137,6 @@ func (s *String) ReadCompactSize(size *int) bool {
return true
}
func (s *String) SkipCompactSize() bool {
var unused int
return s.ReadCompactSize(&unused)
}
// ReadCompactLengthPrefixed reads data prefixed by a CompactSize-encoded
// length field into out. It reports whether the read was successful.
func (s *String) ReadCompactLengthPrefixed(out *String) bool {
@ -159,8 +154,8 @@ func (s *String) ReadCompactLengthPrefixed(out *String) bool {
return true
}
// SkipCompactLengthPrefixed reads a CompactSize-encoded
// length field, then skips that many bytes.
// SkipCompactLengthPrefixed skips a CompactSize-encoded
// length field.
func (s *String) SkipCompactLengthPrefixed() bool {
var length int
if !s.ReadCompactSize(&length) {

View File

@ -30,6 +30,7 @@ type rawTransaction struct {
//joinSplitPubKey []byte
//joinSplitSig []byte
//bindingSigSapling []byte
orchardActions []action
}
// Txin format as described in https://en.bitcoin.it/wiki/Transaction
@ -165,8 +166,8 @@ func (p *spend) ParseFromSlice(data []byte, version uint32) ([]byte, error) {
return []byte(s), nil
}
func (p *spend) ToCompact() *walletrpc.CompactSpend {
return &walletrpc.CompactSpend{
func (p *spend) ToCompact() *walletrpc.CompactSaplingSpend {
return &walletrpc.CompactSaplingSpend{
Nf: p.nullifier,
}
}
@ -212,8 +213,8 @@ func (p *output) ParseFromSlice(data []byte, version uint32) ([]byte, error) {
return []byte(s), nil
}
func (p *output) ToCompact() *walletrpc.CompactOutput {
return &walletrpc.CompactOutput{
func (p *output) ToCompact() *walletrpc.CompactSaplingOutput {
return &walletrpc.CompactSaplingOutput{
Cmu: p.cmu,
Epk: p.ephemeralKey,
Ciphertext: p.encCiphertext[:52],
@ -290,6 +291,51 @@ func (p *joinSplit) ParseFromSlice(data []byte) ([]byte, error) {
return []byte(s), nil
}
type action struct {
//cv []byte // 32
nullifier []byte // 32
//rk []byte // 32
cmx []byte // 32
ephemeralKey []byte // 32
encCiphertext []byte // 580
//outCiphertext []byte // 80
}
func (a *action) ParseFromSlice(data []byte) ([]byte, error) {
s := bytestring.String(data)
if !s.Skip(32) {
return nil, errors.New("could not read action cv")
}
if !s.ReadBytes(&a.nullifier, 32) {
return nil, errors.New("could not read action nullifier")
}
if !s.Skip(32) {
return nil, errors.New("could not read action rk")
}
if !s.ReadBytes(&a.cmx, 32) {
return nil, errors.New("could not read action cmx")
}
if !s.ReadBytes(&a.ephemeralKey, 32) {
return nil, errors.New("could not read action ephemeralKey")
}
if !s.ReadBytes(&a.encCiphertext, 580) {
return nil, errors.New("could not read action encCiphertext")
}
if !s.Skip(80) {
return nil, errors.New("could not read action outCiphertext")
}
return []byte(s), nil
}
func (p *action) ToCompact() *walletrpc.CompactOrchardAction {
return &walletrpc.CompactOrchardAction{
Nullifier: p.nullifier,
Cmx: p.cmx,
EphemeralKey: p.ephemeralKey,
EncCiphertext: p.encCiphertext[:52],
}
}
// Transaction encodes a full (zcashd) transaction.
type Transaction struct {
*rawTransaction
@ -335,8 +381,9 @@ func (tx *Transaction) ToCompact(index int) *walletrpc.CompactTx {
Index: uint64(index), // index is contextual
Hash: tx.GetEncodableHash(),
//Fee: 0, // TODO: calculate fees
Spends: make([]*walletrpc.CompactSpend, len(tx.shieldedSpends)),
Outputs: make([]*walletrpc.CompactOutput, len(tx.shieldedOutputs)),
Spends: make([]*walletrpc.CompactSaplingSpend, len(tx.shieldedSpends)),
Outputs: make([]*walletrpc.CompactSaplingOutput, len(tx.shieldedOutputs)),
Actions: make([]*walletrpc.CompactOrchardAction, len(tx.orchardActions)),
}
for i, spend := range tx.shieldedSpends {
ctx.Spends[i] = spend.ToCompact()
@ -344,6 +391,9 @@ func (tx *Transaction) ToCompact(index int) *walletrpc.CompactTx {
for i, output := range tx.shieldedOutputs {
ctx.Outputs[i] = output.ToCompact()
}
for i, a := range tx.orchardActions {
ctx.Actions[i] = a.ToCompact()
}
return ctx
}
@ -500,8 +550,13 @@ func (tx *Transaction) parseV5(data []byte) ([]byte, error) {
if actionsCount >= (1 << 16) {
return nil, errors.New(fmt.Sprintf("actionsCount (%d) must be less than 2^16", actionsCount))
}
if !s.Skip(820 * actionsCount) {
return nil, errors.New("could not skip vActionsOrchard")
tx.orchardActions = make([]action, actionsCount)
for i := 0; i < actionsCount; i++ {
a := &tx.orchardActions[i]
s, err = a.ParseFromSlice([]byte(s))
if err != nil {
return nil, errors.Wrap(err, "while parsing orchard action")
}
}
if actionsCount > 0 {
if !s.Skip(1) {

View File

@ -4,7 +4,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.27.1
// protoc v3.15.7
// source: compact_formats.proto
@ -138,9 +138,10 @@ type CompactTx struct {
// unset because the calculation requires reference to prior transactions.
// in a pure-Sapling context, the fee will be calculable as:
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
Fee uint32 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"`
Spends []*CompactSpend `protobuf:"bytes,4,rep,name=spends,proto3" json:"spends,omitempty"` // inputs
Outputs []*CompactOutput `protobuf:"bytes,5,rep,name=outputs,proto3" json:"outputs,omitempty"` // outputs
Fee uint32 `protobuf:"varint,3,opt,name=fee,proto3" json:"fee,omitempty"`
Spends []*CompactSaplingSpend `protobuf:"bytes,4,rep,name=spends,proto3" json:"spends,omitempty"` // inputs
Outputs []*CompactSaplingOutput `protobuf:"bytes,5,rep,name=outputs,proto3" json:"outputs,omitempty"` // outputs
Actions []*CompactOrchardAction `protobuf:"bytes,6,rep,name=actions,proto3" json:"actions,omitempty"`
}
func (x *CompactTx) Reset() {
@ -196,23 +197,30 @@ func (x *CompactTx) GetFee() uint32 {
return 0
}
func (x *CompactTx) GetSpends() []*CompactSpend {
func (x *CompactTx) GetSpends() []*CompactSaplingSpend {
if x != nil {
return x.Spends
}
return nil
}
func (x *CompactTx) GetOutputs() []*CompactOutput {
func (x *CompactTx) GetOutputs() []*CompactSaplingOutput {
if x != nil {
return x.Outputs
}
return nil
}
// CompactSpend is a Sapling Spend Description as described in 7.3 of the Zcash
func (x *CompactTx) GetActions() []*CompactOrchardAction {
if x != nil {
return x.Actions
}
return nil
}
// CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
// protocol specification.
type CompactSpend struct {
type CompactSaplingSpend struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@ -220,8 +228,8 @@ type CompactSpend struct {
Nf []byte `protobuf:"bytes,1,opt,name=nf,proto3" json:"nf,omitempty"` // nullifier (see the Zcash protocol specification)
}
func (x *CompactSpend) Reset() {
*x = CompactSpend{}
func (x *CompactSaplingSpend) Reset() {
*x = CompactSaplingSpend{}
if protoimpl.UnsafeEnabled {
mi := &file_compact_formats_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -229,13 +237,13 @@ func (x *CompactSpend) Reset() {
}
}
func (x *CompactSpend) String() string {
func (x *CompactSaplingSpend) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CompactSpend) ProtoMessage() {}
func (*CompactSaplingSpend) ProtoMessage() {}
func (x *CompactSpend) ProtoReflect() protoreflect.Message {
func (x *CompactSaplingSpend) ProtoReflect() protoreflect.Message {
mi := &file_compact_formats_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -247,12 +255,12 @@ func (x *CompactSpend) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use CompactSpend.ProtoReflect.Descriptor instead.
func (*CompactSpend) Descriptor() ([]byte, []int) {
// Deprecated: Use CompactSaplingSpend.ProtoReflect.Descriptor instead.
func (*CompactSaplingSpend) Descriptor() ([]byte, []int) {
return file_compact_formats_proto_rawDescGZIP(), []int{2}
}
func (x *CompactSpend) GetNf() []byte {
func (x *CompactSaplingSpend) GetNf() []byte {
if x != nil {
return x.Nf
}
@ -261,18 +269,18 @@ func (x *CompactSpend) GetNf() []byte {
// output is a Sapling Output Description as described in section 7.4 of the
// Zcash protocol spec. Total size is 948.
type CompactOutput struct {
type CompactSaplingOutput struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Cmu []byte `protobuf:"bytes,1,opt,name=cmu,proto3" json:"cmu,omitempty"` // note commitment u-coordinate
Epk []byte `protobuf:"bytes,2,opt,name=epk,proto3" json:"epk,omitempty"` // ephemeral public key
Ciphertext []byte `protobuf:"bytes,3,opt,name=ciphertext,proto3" json:"ciphertext,omitempty"` // ciphertext and zkproof
Ciphertext []byte `protobuf:"bytes,3,opt,name=ciphertext,proto3" json:"ciphertext,omitempty"` // first 52 bytes of ciphertext
}
func (x *CompactOutput) Reset() {
*x = CompactOutput{}
func (x *CompactSaplingOutput) Reset() {
*x = CompactSaplingOutput{}
if protoimpl.UnsafeEnabled {
mi := &file_compact_formats_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -280,13 +288,13 @@ func (x *CompactOutput) Reset() {
}
}
func (x *CompactOutput) String() string {
func (x *CompactSaplingOutput) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CompactOutput) ProtoMessage() {}
func (*CompactSaplingOutput) ProtoMessage() {}
func (x *CompactOutput) ProtoReflect() protoreflect.Message {
func (x *CompactSaplingOutput) ProtoReflect() protoreflect.Message {
mi := &file_compact_formats_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -298,32 +306,105 @@ func (x *CompactOutput) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use CompactOutput.ProtoReflect.Descriptor instead.
func (*CompactOutput) Descriptor() ([]byte, []int) {
// Deprecated: Use CompactSaplingOutput.ProtoReflect.Descriptor instead.
func (*CompactSaplingOutput) Descriptor() ([]byte, []int) {
return file_compact_formats_proto_rawDescGZIP(), []int{3}
}
func (x *CompactOutput) GetCmu() []byte {
func (x *CompactSaplingOutput) GetCmu() []byte {
if x != nil {
return x.Cmu
}
return nil
}
func (x *CompactOutput) GetEpk() []byte {
func (x *CompactSaplingOutput) GetEpk() []byte {
if x != nil {
return x.Epk
}
return nil
}
func (x *CompactOutput) GetCiphertext() []byte {
func (x *CompactSaplingOutput) GetCiphertext() []byte {
if x != nil {
return x.Ciphertext
}
return nil
}
// https://github.com/zcash/zips/blob/main/zip-0225.rst#orchard-action-description-orchardaction
// (but not all fields are needed)
type CompactOrchardAction struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Nullifier []byte `protobuf:"bytes,1,opt,name=nullifier,proto3" json:"nullifier,omitempty"` // [32] The nullifier of the input note
Cmx []byte `protobuf:"bytes,2,opt,name=cmx,proto3" json:"cmx,omitempty"` // [32] The x-coordinate of the note commitment for the output note
EphemeralKey []byte `protobuf:"bytes,3,opt,name=ephemeralKey,proto3" json:"ephemeralKey,omitempty"` // [32] An encoding of an ephemeral Pallas public key
EncCiphertext []byte `protobuf:"bytes,4,opt,name=encCiphertext,proto3" json:"encCiphertext,omitempty"` // [580] The encrypted contents of the note plaintext
}
func (x *CompactOrchardAction) Reset() {
*x = CompactOrchardAction{}
if protoimpl.UnsafeEnabled {
mi := &file_compact_formats_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CompactOrchardAction) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CompactOrchardAction) ProtoMessage() {}
func (x *CompactOrchardAction) ProtoReflect() protoreflect.Message {
mi := &file_compact_formats_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CompactOrchardAction.ProtoReflect.Descriptor instead.
func (*CompactOrchardAction) Descriptor() ([]byte, []int) {
return file_compact_formats_proto_rawDescGZIP(), []int{4}
}
func (x *CompactOrchardAction) GetNullifier() []byte {
if x != nil {
return x.Nullifier
}
return nil
}
func (x *CompactOrchardAction) GetCmx() []byte {
if x != nil {
return x.Cmx
}
return nil
}
func (x *CompactOrchardAction) GetEphemeralKey() []byte {
if x != nil {
return x.EphemeralKey
}
return nil
}
func (x *CompactOrchardAction) GetEncCiphertext() []byte {
if x != nil {
return x.EncCiphertext
}
return nil
}
var File_compact_formats_proto protoreflect.FileDescriptor
var file_compact_formats_proto_rawDesc = []byte{
@ -343,29 +424,45 @@ var file_compact_formats_proto_rawDesc = []byte{
0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x03, 0x76, 0x74, 0x78, 0x18, 0x07,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x61, 0x73, 0x68, 0x2e, 0x7a, 0x2e, 0x77, 0x61,
0x6c, 0x6c, 0x65, 0x74, 0x2e, 0x73, 0x64, 0x6b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d,
0x70, 0x61, 0x63, 0x74, 0x54, 0x78, 0x52, 0x03, 0x76, 0x74, 0x78, 0x22, 0xc4, 0x01, 0x0a, 0x09,
0x70, 0x61, 0x63, 0x74, 0x54, 0x78, 0x52, 0x03, 0x76, 0x74, 0x78, 0x22, 0x99, 0x02, 0x0a, 0x09,
0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x54, 0x78, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64,
0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12,
0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68,
0x61, 0x73, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x18,
0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x61, 0x73, 0x68, 0x2e, 0x7a, 0x2e, 0x77,
0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x42, 0x0a, 0x06, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x18,
0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x61, 0x73, 0x68, 0x2e, 0x7a, 0x2e, 0x77,
0x61, 0x6c, 0x6c, 0x65, 0x74, 0x2e, 0x73, 0x64, 0x6b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f,
0x6d, 0x70, 0x61, 0x63, 0x74, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x52, 0x06, 0x73, 0x70, 0x65, 0x6e,
0x64, 0x73, 0x12, 0x3e, 0x0a, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x05, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x61, 0x73, 0x68, 0x2e, 0x7a, 0x2e, 0x77, 0x61, 0x6c,
0x6c, 0x65, 0x74, 0x2e, 0x73, 0x64, 0x6b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x70,
0x61, 0x63, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x73, 0x22, 0x1e, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x53, 0x70, 0x65,
0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02,
0x6e, 0x66, 0x22, 0x53, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x4f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x75, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x03, 0x63, 0x6d, 0x75, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x70, 0x6b, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x03, 0x65, 0x70, 0x6b, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x69, 0x70, 0x68, 0x65,
0x72, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x69, 0x70,
0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x42, 0x1b, 0x5a, 0x16, 0x6c, 0x69, 0x67, 0x68, 0x74,
0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x72, 0x70,
0x63, 0xba, 0x02, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6d, 0x70, 0x61, 0x63, 0x74, 0x53, 0x61, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x70, 0x65, 0x6e,
0x64, 0x52, 0x06, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x45, 0x0a, 0x07, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x61, 0x73,
0x68, 0x2e, 0x7a, 0x2e, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x2e, 0x73, 0x64, 0x6b, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x53, 0x61, 0x70, 0x6c, 0x69, 0x6e,
0x67, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73,
0x12, 0x45, 0x0a, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x61, 0x73, 0x68, 0x2e, 0x7a, 0x2e, 0x77, 0x61, 0x6c, 0x6c, 0x65,
0x74, 0x2e, 0x73, 0x64, 0x6b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63,
0x74, 0x4f, 0x72, 0x63, 0x68, 0x61, 0x72, 0x64, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x25, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x61,
0x63, 0x74, 0x53, 0x61, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x0e,
0x0a, 0x02, 0x6e, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x6e, 0x66, 0x22, 0x5a,
0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x53, 0x61, 0x70, 0x6c, 0x69, 0x6e, 0x67,
0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x75, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x6d, 0x75, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x70, 0x6b, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x65, 0x70, 0x6b, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x69,
0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a,
0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x43,
0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x4f, 0x72, 0x63, 0x68, 0x61, 0x72, 0x64, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x69, 0x66, 0x69, 0x65, 0x72,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x69, 0x66, 0x69, 0x65,
0x72, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03,
0x63, 0x6d, 0x78, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c,
0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, 0x70, 0x68, 0x65, 0x6d,
0x65, 0x72, 0x61, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x65, 0x6e, 0x63, 0x43, 0x69,
0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d,
0x65, 0x6e, 0x63, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x42, 0x1b, 0x5a,
0x16, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x64, 0x2f, 0x77, 0x61,
0x6c, 0x6c, 0x65, 0x74, 0x72, 0x70, 0x63, 0xba, 0x02, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@ -380,22 +477,24 @@ func file_compact_formats_proto_rawDescGZIP() []byte {
return file_compact_formats_proto_rawDescData
}
var file_compact_formats_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_compact_formats_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_compact_formats_proto_goTypes = []interface{}{
(*CompactBlock)(nil), // 0: cash.z.wallet.sdk.rpc.CompactBlock
(*CompactTx)(nil), // 1: cash.z.wallet.sdk.rpc.CompactTx
(*CompactSpend)(nil), // 2: cash.z.wallet.sdk.rpc.CompactSpend
(*CompactOutput)(nil), // 3: cash.z.wallet.sdk.rpc.CompactOutput
(*CompactBlock)(nil), // 0: cash.z.wallet.sdk.rpc.CompactBlock
(*CompactTx)(nil), // 1: cash.z.wallet.sdk.rpc.CompactTx
(*CompactSaplingSpend)(nil), // 2: cash.z.wallet.sdk.rpc.CompactSaplingSpend
(*CompactSaplingOutput)(nil), // 3: cash.z.wallet.sdk.rpc.CompactSaplingOutput
(*CompactOrchardAction)(nil), // 4: cash.z.wallet.sdk.rpc.CompactOrchardAction
}
var file_compact_formats_proto_depIdxs = []int32{
1, // 0: cash.z.wallet.sdk.rpc.CompactBlock.vtx:type_name -> cash.z.wallet.sdk.rpc.CompactTx
2, // 1: cash.z.wallet.sdk.rpc.CompactTx.spends:type_name -> cash.z.wallet.sdk.rpc.CompactSpend
3, // 2: cash.z.wallet.sdk.rpc.CompactTx.outputs:type_name -> cash.z.wallet.sdk.rpc.CompactOutput
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
2, // 1: cash.z.wallet.sdk.rpc.CompactTx.spends:type_name -> cash.z.wallet.sdk.rpc.CompactSaplingSpend
3, // 2: cash.z.wallet.sdk.rpc.CompactTx.outputs:type_name -> cash.z.wallet.sdk.rpc.CompactSaplingOutput
4, // 3: cash.z.wallet.sdk.rpc.CompactTx.actions:type_name -> cash.z.wallet.sdk.rpc.CompactOrchardAction
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_compact_formats_proto_init() }
@ -429,7 +528,7 @@ func file_compact_formats_proto_init() {
}
}
file_compact_formats_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CompactSpend); i {
switch v := v.(*CompactSaplingSpend); i {
case 0:
return &v.state
case 1:
@ -441,7 +540,19 @@ func file_compact_formats_proto_init() {
}
}
file_compact_formats_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CompactOutput); i {
switch v := v.(*CompactSaplingOutput); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_compact_formats_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CompactOrchardAction); i {
case 0:
return &v.state
case 1:
@ -459,7 +570,7 @@ func file_compact_formats_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_compact_formats_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -37,20 +37,30 @@ message CompactTx {
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
uint32 fee = 3;
repeated CompactSpend spends = 4; // inputs
repeated CompactOutput outputs = 5; // outputs
repeated CompactSaplingSpend spends = 4; // inputs
repeated CompactSaplingOutput outputs = 5; // outputs
repeated CompactOrchardAction actions = 6;
}
// CompactSpend is a Sapling Spend Description as described in 7.3 of the Zcash
// CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
// protocol specification.
message CompactSpend {
message CompactSaplingSpend {
bytes nf = 1; // nullifier (see the Zcash protocol specification)
}
// output is a Sapling Output Description as described in section 7.4 of the
// Zcash protocol spec. Total size is 948.
message CompactOutput {
message CompactSaplingOutput {
bytes cmu = 1; // note commitment u-coordinate
bytes epk = 2; // ephemeral public key
bytes ciphertext = 3; // ciphertext and zkproof
bytes ciphertext = 3; // first 52 bytes of ciphertext
}
// https://github.com/zcash/zips/blob/main/zip-0225.rst#orchard-action-description-orchardaction
// (but not all fields are needed)
message CompactOrchardAction {
bytes nullifier = 1; // [32] The nullifier of the input note
bytes cmx = 2; // [32] The x-coordinate of the note commitment for the output note
bytes ephemeralKey = 3; // [32] An encoding of an ephemeral Pallas public key
bytes encCiphertext = 4; // [580] The encrypted contents of the note plaintext
}

View File

@ -4,7 +4,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.27.1
// protoc v3.15.7
// source: darkside.proto

View File

@ -4,7 +4,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.27.1
// protoc v3.15.7
// source: service.proto