storj/pkg/auth/signing/encode.go
Egon Elbre 05d148aeb5
Storage node and upload/download protocol refactor (#1422)
refactor storage node server
refactor upload and download protocol
2019-03-18 12:55:06 +02:00

35 lines
962 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package signing
import (
"github.com/gogo/protobuf/proto"
"storj.io/storj/pkg/pb"
)
// EncodeOrderLimit encodes order limit into bytes for signing.
func EncodeOrderLimit(limit *pb.OrderLimit2) ([]byte, error) {
signature := limit.SatelliteSignature
limit.SatelliteSignature = nil
defer func() { limit.SatelliteSignature = signature }()
return proto.Marshal(limit)
}
// EncodeOrder encodes order into bytes for signing.
func EncodeOrder(order *pb.Order2) ([]byte, error) {
signature := order.UplinkSignature
order.UplinkSignature = nil
defer func() { order.UplinkSignature = signature }()
return proto.Marshal(order)
}
// EncodePieceHash encodes piece hash into bytes for signing.
func EncodePieceHash(hash *pb.PieceHash) ([]byte, error) {
signature := hash.Signature
hash.Signature = nil
defer func() { hash.Signature = signature }()
return proto.Marshal(hash)
}