Skip to content

Commit

Permalink
rebuild protobufs adding ECC_P256 to KeyType
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Apr 27, 2024
1 parent 827d16b commit c770a05
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 91 deletions.
16 changes: 7 additions & 9 deletions libp2p/crypto/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

@unique
class KeyType(Enum):
RSA = 0
Ed25519 = 1
Secp256k1 = 2
ECDSA = 3
ECC_P256 = 4
RSA = protobuf.KeyType.RSA
Ed25519 = protobuf.KeyType.Ed25519
Secp256k1 = protobuf.KeyType.Secp256k1
ECDSA = protobuf.KeyType.ECDSA
ECC_P256 = protobuf.KeyType.ECC_P256


class Key(ABC):
Expand Down Expand Up @@ -56,8 +56,7 @@ def _serialize_to_protobuf(self) -> protobuf.PublicKey:
"""Return the protobuf representation of this ``Key``."""
key_type = self.get_type().value
data = self.to_bytes()
# type ignored - TODO add ECD_P256 to KeyType
protobuf_key = protobuf.PublicKey(key_type=key_type, data=data) # type: ignore
protobuf_key = protobuf.PublicKey(key_type=key_type, data=data)
return protobuf_key

def serialize(self) -> bytes:
Expand All @@ -84,8 +83,7 @@ def _serialize_to_protobuf(self) -> protobuf.PrivateKey:
"""Return the protobuf representation of this ``Key``."""
key_type = self.get_type().value
data = self.to_bytes()
# type ignored - TODO add ECD_P256 to KeyType
protobuf_key = protobuf.PrivateKey(key_type=key_type, data=data) # type: ignore
protobuf_key = protobuf.PrivateKey(key_type=key_type, data=data)
return protobuf_key

def serialize(self) -> bytes:
Expand Down
1 change: 1 addition & 0 deletions libp2p/crypto/pb/crypto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum KeyType {
Ed25519 = 1;
Secp256k1 = 2;
ECDSA = 3;
ECC_P256 = 4;
}

message PublicKey {
Expand Down
4 changes: 2 additions & 2 deletions libp2p/crypto/pb/crypto_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions libp2p/crypto/pb/crypto_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import builtins
import google.protobuf.descriptor
import google.protobuf.internal.enum_type_wrapper
Expand All @@ -26,16 +27,18 @@ class _KeyTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTy
Ed25519: _KeyType.ValueType # 1
Secp256k1: _KeyType.ValueType # 2
ECDSA: _KeyType.ValueType # 3
ECC_P256: _KeyType.ValueType # 4

class KeyType(_KeyType, metaclass=_KeyTypeEnumTypeWrapper): ...

RSA: KeyType.ValueType # 0
Ed25519: KeyType.ValueType # 1
Secp256k1: KeyType.ValueType # 2
ECDSA: KeyType.ValueType # 3
ECC_P256: KeyType.ValueType # 4
global___KeyType = KeyType

@typing_extensions.final
@typing.final
class PublicKey(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -49,12 +52,12 @@ class PublicKey(google.protobuf.message.Message):
key_type: global___KeyType.ValueType | None = ...,
data: builtins.bytes | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["data", b"data", "key_type", b"key_type"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["data", b"data", "key_type", b"key_type"]) -> None: ...
def HasField(self, field_name: typing.Literal["data", b"data", "key_type", b"key_type"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["data", b"data", "key_type", b"key_type"]) -> None: ...

global___PublicKey = PublicKey

@typing_extensions.final
@typing.final
class PrivateKey(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -68,7 +71,7 @@ class PrivateKey(google.protobuf.message.Message):
key_type: global___KeyType.ValueType | None = ...,
data: builtins.bytes | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["data", b"data", "key_type", b"key_type"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["data", b"data", "key_type", b"key_type"]) -> None: ...
def HasField(self, field_name: typing.Literal["data", b"data", "key_type", b"key_type"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["data", b"data", "key_type", b"key_type"]) -> None: ...

global___PrivateKey = PrivateKey
16 changes: 6 additions & 10 deletions libp2p/identity/identify/pb/identify_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import builtins
import collections.abc
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.message
import sys

if sys.version_info >= (3, 8):
import typing as typing_extensions
else:
import typing_extensions
import typing

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing_extensions.final
@typing.final
class Identify(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -29,9 +25,9 @@ class Identify(google.protobuf.message.Message):
protocol_version: builtins.str
agent_version: builtins.str
public_key: builtins.bytes
observed_addr: builtins.bytes
@property
def listen_addrs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bytes]: ...
observed_addr: builtins.bytes
@property
def protocols(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
def __init__(
Expand All @@ -44,7 +40,7 @@ class Identify(google.protobuf.message.Message):
observed_addr: builtins.bytes | None = ...,
protocols: collections.abc.Iterable[builtins.str] | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["agent_version", b"agent_version", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "public_key", b"public_key"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["agent_version", b"agent_version", "listen_addrs", b"listen_addrs", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "protocols", b"protocols", "public_key", b"public_key"]) -> None: ...
def HasField(self, field_name: typing.Literal["agent_version", b"agent_version", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "public_key", b"public_key"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["agent_version", b"agent_version", "listen_addrs", b"listen_addrs", "observed_addr", b"observed_addr", "protocol_version", b"protocol_version", "protocols", b"protocols", "public_key", b"public_key"]) -> None: ...

global___Identify = Identify
69 changes: 36 additions & 33 deletions libp2p/pubsub/pb/rpc_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
Modified from https://github.com/libp2p/go-libp2p-pubsub/blob/master/pb/rpc.proto"""

import builtins
import collections.abc
import google.protobuf.descriptor
Expand All @@ -18,11 +19,11 @@ else:

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing_extensions.final
@typing.final
class RPC(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

@typing_extensions.final
@typing.final
class SubOpts(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -37,8 +38,8 @@ class RPC(google.protobuf.message.Message):
subscribe: builtins.bool | None = ...,
topicid: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["subscribe", b"subscribe", "topicid", b"topicid"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["subscribe", b"subscribe", "topicid", b"topicid"]) -> None: ...
def HasField(self, field_name: typing.Literal["subscribe", b"subscribe", "topicid", b"topicid"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["subscribe", b"subscribe", "topicid", b"topicid"]) -> None: ...

SUBSCRIPTIONS_FIELD_NUMBER: builtins.int
PUBLISH_FIELD_NUMBER: builtins.int
Expand All @@ -56,12 +57,12 @@ class RPC(google.protobuf.message.Message):
publish: collections.abc.Iterable[global___Message] | None = ...,
control: global___ControlMessage | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["control", b"control"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["control", b"control", "publish", b"publish", "subscriptions", b"subscriptions"]) -> None: ...
def HasField(self, field_name: typing.Literal["control", b"control"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["control", b"control", "publish", b"publish", "subscriptions", b"subscriptions"]) -> None: ...

global___RPC = RPC

@typing_extensions.final
@typing.final
class Message(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -74,10 +75,10 @@ class Message(google.protobuf.message.Message):
from_id: builtins.bytes
data: builtins.bytes
seqno: builtins.bytes
@property
def topicIDs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
signature: builtins.bytes
key: builtins.bytes
@property
def topicIDs(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
def __init__(
self,
*,
Expand All @@ -88,12 +89,12 @@ class Message(google.protobuf.message.Message):
signature: builtins.bytes | None = ...,
key: builtins.bytes | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["data", b"data", "from_id", b"from_id", "key", b"key", "seqno", b"seqno", "signature", b"signature"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["data", b"data", "from_id", b"from_id", "key", b"key", "seqno", b"seqno", "signature", b"signature", "topicIDs", b"topicIDs"]) -> None: ...
def HasField(self, field_name: typing.Literal["data", b"data", "from_id", b"from_id", "key", b"key", "seqno", b"seqno", "signature", b"signature"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["data", b"data", "from_id", b"from_id", "key", b"key", "seqno", b"seqno", "signature", b"signature", "topicIDs", b"topicIDs"]) -> None: ...

global___Message = Message

@typing_extensions.final
@typing.final
class ControlMessage(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -117,11 +118,11 @@ class ControlMessage(google.protobuf.message.Message):
graft: collections.abc.Iterable[global___ControlGraft] | None = ...,
prune: collections.abc.Iterable[global___ControlPrune] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["graft", b"graft", "ihave", b"ihave", "iwant", b"iwant", "prune", b"prune"]) -> None: ...
def ClearField(self, field_name: typing.Literal["graft", b"graft", "ihave", b"ihave", "iwant", b"iwant", "prune", b"prune"]) -> None: ...

global___ControlMessage = ControlMessage

@typing_extensions.final
@typing.final
class ControlIHave(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -136,12 +137,12 @@ class ControlIHave(google.protobuf.message.Message):
topicID: builtins.str | None = ...,
messageIDs: collections.abc.Iterable[builtins.str] | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["messageIDs", b"messageIDs", "topicID", b"topicID"]) -> None: ...
def HasField(self, field_name: typing.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["messageIDs", b"messageIDs", "topicID", b"topicID"]) -> None: ...

global___ControlIHave = ControlIHave

@typing_extensions.final
@typing.final
class ControlIWant(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -153,11 +154,11 @@ class ControlIWant(google.protobuf.message.Message):
*,
messageIDs: collections.abc.Iterable[builtins.str] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["messageIDs", b"messageIDs"]) -> None: ...
def ClearField(self, field_name: typing.Literal["messageIDs", b"messageIDs"]) -> None: ...

global___ControlIWant = ControlIWant

@typing_extensions.final
@typing.final
class ControlGraft(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -168,12 +169,12 @@ class ControlGraft(google.protobuf.message.Message):
*,
topicID: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["topicID", b"topicID"]) -> None: ...
def HasField(self, field_name: typing.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["topicID", b"topicID"]) -> None: ...

global___ControlGraft = ControlGraft

@typing_extensions.final
@typing.final
class ControlPrune(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand All @@ -184,16 +185,16 @@ class ControlPrune(google.protobuf.message.Message):
*,
topicID: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["topicID", b"topicID"]) -> None: ...
def HasField(self, field_name: typing.Literal["topicID", b"topicID"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["topicID", b"topicID"]) -> None: ...

global___ControlPrune = ControlPrune

@typing_extensions.final
@typing.final
class TopicDescriptor(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

@typing_extensions.final
@typing.final
class AuthOpts(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand Down Expand Up @@ -224,16 +225,17 @@ class TopicDescriptor(google.protobuf.message.Message):
@property
def keys(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bytes]:
"""root keys to trust"""

def __init__(
self,
*,
mode: global___TopicDescriptor.AuthOpts.AuthMode.ValueType | None = ...,
keys: collections.abc.Iterable[builtins.bytes] | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["mode", b"mode"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["keys", b"keys", "mode", b"mode"]) -> None: ...
def HasField(self, field_name: typing.Literal["mode", b"mode"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["keys", b"keys", "mode", b"mode"]) -> None: ...

@typing_extensions.final
@typing.final
class EncOpts(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

Expand Down Expand Up @@ -264,14 +266,15 @@ class TopicDescriptor(google.protobuf.message.Message):
@property
def keyHashes(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bytes]:
"""the hashes of the shared keys used (salted)"""

def __init__(
self,
*,
mode: global___TopicDescriptor.EncOpts.EncMode.ValueType | None = ...,
keyHashes: collections.abc.Iterable[builtins.bytes] | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["mode", b"mode"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["keyHashes", b"keyHashes", "mode", b"mode"]) -> None: ...
def HasField(self, field_name: typing.Literal["mode", b"mode"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["keyHashes", b"keyHashes", "mode", b"mode"]) -> None: ...

NAME_FIELD_NUMBER: builtins.int
AUTH_FIELD_NUMBER: builtins.int
Expand All @@ -288,7 +291,7 @@ class TopicDescriptor(google.protobuf.message.Message):
auth: global___TopicDescriptor.AuthOpts | None = ...,
enc: global___TopicDescriptor.EncOpts | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["auth", b"auth", "enc", b"enc", "name", b"name"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["auth", b"auth", "enc", b"enc", "name", b"name"]) -> None: ...
def HasField(self, field_name: typing.Literal["auth", b"auth", "enc", b"enc", "name", b"name"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["auth", b"auth", "enc", b"enc", "name", b"name"]) -> None: ...

global___TopicDescriptor = TopicDescriptor
Loading

0 comments on commit c770a05

Please sign in to comment.