[#380] Support changes in signature schemes

Support new `SignatureRFC6979` message. Make `refs.ECDSA_SHA512` to be
default scheme.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-03-02 13:15:36 +03:00 committed by Alex Vanin
parent f4fd28e39b
commit d065453bd0
9 changed files with 470 additions and 368 deletions

168
refs/grpc/types.pb.go generated
View file

@ -24,25 +24,21 @@ const (
type SignatureScheme int32
const (
// Unknown. The default interpretation depends on a particular structure type.
SignatureScheme_UNSPECIFIED SignatureScheme = 0
// ECDSA with SHA-512 hashing (FIPS 186-3).
SignatureScheme_ECDSA_SHA512 SignatureScheme = 1
// ECDSA with SHA-512 hashing (FIPS 186-3)
SignatureScheme_ECDSA_SHA512 SignatureScheme = 0
// Deterministic ECDSA with SHA-256 hashing (RFC 6979)
SignatureScheme_ECDSA_RFC6979_SHA256 SignatureScheme = 2
SignatureScheme_ECDSA_RFC6979_SHA256 SignatureScheme = 1
)
// Enum value maps for SignatureScheme.
var (
SignatureScheme_name = map[int32]string{
0: "UNSPECIFIED",
1: "ECDSA_SHA512",
2: "ECDSA_RFC6979_SHA256",
0: "ECDSA_SHA512",
1: "ECDSA_RFC6979_SHA256",
}
SignatureScheme_value = map[string]int32{
"UNSPECIFIED": 0,
"ECDSA_SHA512": 1,
"ECDSA_RFC6979_SHA256": 2,
"ECDSA_SHA512": 0,
"ECDSA_RFC6979_SHA256": 1,
}
)
@ -501,7 +497,7 @@ type Signature struct {
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// Signature
Sign []byte `protobuf:"bytes,2,opt,name=sign,json=signature,proto3" json:"sign,omitempty"`
// Scheme contains digital signature scheme identifier.
// Scheme contains digital signature scheme identifier
Scheme SignatureScheme `protobuf:"varint,3,opt,name=scheme,proto3,enum=neo.fs.v2.refs.SignatureScheme" json:"scheme,omitempty"`
}
@ -555,7 +551,65 @@ func (x *Signature) GetScheme() SignatureScheme {
if x != nil {
return x.Scheme
}
return SignatureScheme_UNSPECIFIED
return SignatureScheme_ECDSA_SHA512
}
// RFC 6979 signature.
type SignatureRFC6979 struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Public key used for signing
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// Deterministic ECDSA with SHA-256 hashing
Sign []byte `protobuf:"bytes,2,opt,name=sign,json=signature,proto3" json:"sign,omitempty"`
}
func (x *SignatureRFC6979) Reset() {
*x = SignatureRFC6979{}
if protoimpl.UnsafeEnabled {
mi := &file_refs_grpc_types_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SignatureRFC6979) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SignatureRFC6979) ProtoMessage() {}
func (x *SignatureRFC6979) ProtoReflect() protoreflect.Message {
mi := &file_refs_grpc_types_proto_msgTypes[7]
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 SignatureRFC6979.ProtoReflect.Descriptor instead.
func (*SignatureRFC6979) Descriptor() ([]byte, []int) {
return file_refs_grpc_types_proto_rawDescGZIP(), []int{7}
}
func (x *SignatureRFC6979) GetKey() []byte {
if x != nil {
return x.Key
}
return nil
}
func (x *SignatureRFC6979) GetSign() []byte {
if x != nil {
return x.Sign
}
return nil
}
// Checksum message.
@ -579,7 +633,7 @@ type Checksum struct {
func (x *Checksum) Reset() {
*x = Checksum{}
if protoimpl.UnsafeEnabled {
mi := &file_refs_grpc_types_proto_msgTypes[7]
mi := &file_refs_grpc_types_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -592,7 +646,7 @@ func (x *Checksum) String() string {
func (*Checksum) ProtoMessage() {}
func (x *Checksum) ProtoReflect() protoreflect.Message {
mi := &file_refs_grpc_types_proto_msgTypes[7]
mi := &file_refs_grpc_types_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -605,7 +659,7 @@ func (x *Checksum) ProtoReflect() protoreflect.Message {
// Deprecated: Use Checksum.ProtoReflect.Descriptor instead.
func (*Checksum) Descriptor() ([]byte, []int) {
return file_refs_grpc_types_proto_rawDescGZIP(), []int{7}
return file_refs_grpc_types_proto_rawDescGZIP(), []int{8}
}
func (x *Checksum) GetType() ChecksumType {
@ -654,27 +708,30 @@ var file_refs_grpc_types_proto_rawDesc = []byte{
0x75, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e,
0x72, 0x65, 0x66, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63,
0x68, 0x65, 0x6d, 0x65, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x22, 0x4e, 0x0a, 0x08,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e,
0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d,
0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x75,
0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x2a, 0x4e, 0x0a, 0x0f,
0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12,
0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,
0x12, 0x10, 0x0a, 0x0c, 0x45, 0x43, 0x44, 0x53, 0x41, 0x5f, 0x53, 0x48, 0x41, 0x35, 0x31, 0x32,
0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x45, 0x43, 0x44, 0x53, 0x41, 0x5f, 0x52, 0x46, 0x43, 0x36,
0x39, 0x37, 0x39, 0x5f, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x10, 0x02, 0x2a, 0x41, 0x0a, 0x0c,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19,
0x43, 0x48, 0x45, 0x43, 0x4b, 0x53, 0x55, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e,
0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x54,
0x5a, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x10, 0x02, 0x42,
0x50, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73,
0x70, 0x63, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70,
0x69, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72, 0x70,
0x63, 0x3b, 0x72, 0x65, 0x66, 0x73, 0xaa, 0x02, 0x18, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69, 0x6c,
0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x52, 0x65, 0x66,
0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x68, 0x65, 0x6d, 0x65, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x22, 0x3d, 0x0a, 0x10,
0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x46, 0x43, 0x36, 0x39, 0x37, 0x39,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x69, 0x67, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x4e, 0x0a, 0x08, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76,
0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x54,
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x75, 0x6d,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x2a, 0x3d, 0x0a, 0x0f, 0x53,
0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x10,
0x0a, 0x0c, 0x45, 0x43, 0x44, 0x53, 0x41, 0x5f, 0x53, 0x48, 0x41, 0x35, 0x31, 0x32, 0x10, 0x00,
0x12, 0x18, 0x0a, 0x14, 0x45, 0x43, 0x44, 0x53, 0x41, 0x5f, 0x52, 0x46, 0x43, 0x36, 0x39, 0x37,
0x39, 0x5f, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x10, 0x01, 0x2a, 0x41, 0x0a, 0x0c, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x48,
0x45, 0x43, 0x4b, 0x53, 0x55, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50,
0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x54, 0x5a, 0x10,
0x01, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x10, 0x02, 0x42, 0x50, 0x5a,
0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63,
0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d,
0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b,
0x72, 0x65, 0x66, 0x73, 0xaa, 0x02, 0x18, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x53,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x52, 0x65, 0x66, 0x73, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -690,18 +747,19 @@ func file_refs_grpc_types_proto_rawDescGZIP() []byte {
}
var file_refs_grpc_types_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_refs_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_refs_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_refs_grpc_types_proto_goTypes = []interface{}{
(SignatureScheme)(0), // 0: neo.fs.v2.refs.SignatureScheme
(ChecksumType)(0), // 1: neo.fs.v2.refs.ChecksumType
(*Address)(nil), // 2: neo.fs.v2.refs.Address
(*ObjectID)(nil), // 3: neo.fs.v2.refs.ObjectID
(*ContainerID)(nil), // 4: neo.fs.v2.refs.ContainerID
(*OwnerID)(nil), // 5: neo.fs.v2.refs.OwnerID
(*SubnetID)(nil), // 6: neo.fs.v2.refs.SubnetID
(*Version)(nil), // 7: neo.fs.v2.refs.Version
(*Signature)(nil), // 8: neo.fs.v2.refs.Signature
(*Checksum)(nil), // 9: neo.fs.v2.refs.Checksum
(SignatureScheme)(0), // 0: neo.fs.v2.refs.SignatureScheme
(ChecksumType)(0), // 1: neo.fs.v2.refs.ChecksumType
(*Address)(nil), // 2: neo.fs.v2.refs.Address
(*ObjectID)(nil), // 3: neo.fs.v2.refs.ObjectID
(*ContainerID)(nil), // 4: neo.fs.v2.refs.ContainerID
(*OwnerID)(nil), // 5: neo.fs.v2.refs.OwnerID
(*SubnetID)(nil), // 6: neo.fs.v2.refs.SubnetID
(*Version)(nil), // 7: neo.fs.v2.refs.Version
(*Signature)(nil), // 8: neo.fs.v2.refs.Signature
(*SignatureRFC6979)(nil), // 9: neo.fs.v2.refs.SignatureRFC6979
(*Checksum)(nil), // 10: neo.fs.v2.refs.Checksum
}
var file_refs_grpc_types_proto_depIdxs = []int32{
4, // 0: neo.fs.v2.refs.Address.container_id:type_name -> neo.fs.v2.refs.ContainerID
@ -806,6 +864,18 @@ func file_refs_grpc_types_proto_init() {
}
}
file_refs_grpc_types_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SignatureRFC6979); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_refs_grpc_types_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Checksum); i {
case 0:
return &v.state
@ -824,7 +894,7 @@ func file_refs_grpc_types_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_refs_grpc_types_proto_rawDesc,
NumEnums: 2,
NumMessages: 8,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},