1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

common/protob: Add GetOwnershipProof message.

This commit is contained in:
Andrew Kozlik 2020-06-09 17:46:52 +02:00 committed by Andrew Kozlik
parent d48a372ca7
commit c723c78529
11 changed files with 195 additions and 1 deletions

View File

@ -250,3 +250,28 @@ message TxAck {
}
}
}
/**
* Request: Ask device for a proof of ownership corresponding to address_n path
* @start
* @next OwnershipProof
* @next Failure
*/
message GetOwnershipProof {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional string coin_name = 2 [default='Bitcoin']; // coin to use
optional InputScriptType script_type = 3 [default=SPENDWITNESS]; // used to distinguish between various scriptPubKey types
optional MultisigRedeemScriptType multisig = 4; // filled if proof is for a multisig address
optional bool user_confirmation = 5; // show a confirmation dialog and set the "user confirmation" bit in the proof
repeated bytes ownership_ids = 6; // list of ownership identifiers in case of multisig
optional bytes commitment_data = 7; // additional data to which the proof should commit
}
/**
* Response: Contains the proof of ownership
* @end
*/
message OwnershipProof {
required bytes ownership_proof = 1; // SLIP-0019 proof of ownership
required bytes signature = 2; // signature of the proof
}

View File

@ -87,6 +87,8 @@ enum MessageType {
MessageType_SignMessage = 38 [(wire_in) = true];
MessageType_VerifyMessage = 39 [(wire_in) = true];
MessageType_MessageSignature = 40 [(wire_out) = true];
MessageType_GetOwnershipProof = 49 [(wire_in) = true];
MessageType_OwnershipProof = 50 [(wire_out) = true];
// Crypto
MessageType_CipherKeyValue = 23 [(wire_in) = true];

View File

@ -0,0 +1,47 @@
# Automatically generated by pb2py
# fmt: off
import protobuf as p
from .MultisigRedeemScriptType import MultisigRedeemScriptType
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
except ImportError:
pass
class GetOwnershipProof(p.MessageType):
MESSAGE_WIRE_TYPE = 49
def __init__(
self,
address_n: List[int] = None,
coin_name: str = None,
script_type: EnumTypeInputScriptType = None,
multisig: MultisigRedeemScriptType = None,
user_confirmation: bool = None,
ownership_ids: List[bytes] = None,
commitment_data: bytes = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.coin_name = coin_name
self.script_type = script_type
self.multisig = multisig
self.user_confirmation = user_confirmation
self.ownership_ids = ownership_ids if ownership_ids is not None else []
self.commitment_data = commitment_data
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('coin_name', p.UnicodeType, 0), # default=Bitcoin
3: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDWITNESS
4: ('multisig', MultisigRedeemScriptType, 0),
5: ('user_confirmation', p.BoolType, 0),
6: ('ownership_ids', p.BytesType, p.FLAG_REPEATED),
7: ('commitment_data', p.BytesType, 0),
}

View File

@ -55,6 +55,8 @@ Address = 30 # type: Literal[30]
SignMessage = 38 # type: Literal[38]
VerifyMessage = 39 # type: Literal[39]
MessageSignature = 40 # type: Literal[40]
GetOwnershipProof = 49 # type: Literal[49]
OwnershipProof = 50 # type: Literal[50]
CipherKeyValue = 23 # type: Literal[23]
CipheredKeyValue = 48 # type: Literal[48]
SignIdentity = 53 # type: Literal[53]

View File

@ -0,0 +1,29 @@
# Automatically generated by pb2py
# fmt: off
import protobuf as p
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
class OwnershipProof(p.MessageType):
MESSAGE_WIRE_TYPE = 50
def __init__(
self,
ownership_proof: bytes = None,
signature: bytes = None,
) -> None:
self.ownership_proof = ownership_proof
self.signature = signature
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('ownership_proof', p.BytesType, 0), # required
2: ('signature', p.BytesType, 0), # required
}

View File

@ -3,7 +3,8 @@ Q := @
endif
SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \
DebugLinkRecordScreen DebugLinkReseedRandom DebugLinkShowText DebugLinkEraseSdCard DebugLinkWatchLayout
DebugLinkRecordScreen DebugLinkReseedRandom DebugLinkShowText DebugLinkEraseSdCard DebugLinkWatchLayout \
GetOwnershipProof OwnershipProof
ifeq ($(BITCOIN_ONLY), 1)
SKIPPED_MESSAGES += Ethereum Lisk NEM Stellar

View File

@ -50,3 +50,11 @@ MultisigRedeemScriptType.nodes max_count:15
MultisigRedeemScriptType.address_n max_count:8
HDNodePathType.address_n max_count:8
GetOwnershipProof.address_n max_count:8
GetOwnershipProof.coin_name max_size:21
GetOwnershipProof.ownership_ids max_count:15 max_size:32
GetOwnershipProof.commitment_data max_size:32
OwnershipProof.ownership_proof max_size:171
OwnershipProof.signature max_size:65

View File

@ -0,0 +1,47 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .MultisigRedeemScriptType import MultisigRedeemScriptType
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
except ImportError:
pass
class GetOwnershipProof(p.MessageType):
MESSAGE_WIRE_TYPE = 49
def __init__(
self,
address_n: List[int] = None,
coin_name: str = None,
script_type: EnumTypeInputScriptType = None,
multisig: MultisigRedeemScriptType = None,
user_confirmation: bool = None,
ownership_ids: List[bytes] = None,
commitment_data: bytes = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.coin_name = coin_name
self.script_type = script_type
self.multisig = multisig
self.user_confirmation = user_confirmation
self.ownership_ids = ownership_ids if ownership_ids is not None else []
self.commitment_data = commitment_data
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('coin_name', p.UnicodeType, 0), # default=Bitcoin
3: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDWITNESS
4: ('multisig', MultisigRedeemScriptType, 0),
5: ('user_confirmation', p.BoolType, 0),
6: ('ownership_ids', p.BytesType, p.FLAG_REPEATED),
7: ('commitment_data', p.BytesType, 0),
}

View File

@ -53,6 +53,8 @@ Address = 30 # type: Literal[30]
SignMessage = 38 # type: Literal[38]
VerifyMessage = 39 # type: Literal[39]
MessageSignature = 40 # type: Literal[40]
GetOwnershipProof = 49 # type: Literal[49]
OwnershipProof = 50 # type: Literal[50]
CipherKeyValue = 23 # type: Literal[23]
CipheredKeyValue = 48 # type: Literal[48]
SignIdentity = 53 # type: Literal[53]

View File

@ -0,0 +1,29 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
class OwnershipProof(p.MessageType):
MESSAGE_WIRE_TYPE = 50
def __init__(
self,
ownership_proof: bytes = None,
signature: bytes = None,
) -> None:
self.ownership_proof = ownership_proof
self.signature = signature
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('ownership_proof', p.BytesType, 0), # required
2: ('signature', p.BytesType, 0), # required
}

View File

@ -111,6 +111,7 @@ from .GetECDHSessionKey import GetECDHSessionKey
from .GetEntropy import GetEntropy
from .GetFeatures import GetFeatures
from .GetNextU2FCounter import GetNextU2FCounter
from .GetOwnershipProof import GetOwnershipProof
from .GetPublicKey import GetPublicKey
from .HDNodePathType import HDNodePathType
from .HDNodeType import HDNodeType
@ -199,6 +200,7 @@ from .NEMSignedTx import NEMSignedTx
from .NEMTransactionCommon import NEMTransactionCommon
from .NEMTransfer import NEMTransfer
from .NextU2FCounter import NextU2FCounter
from .OwnershipProof import OwnershipProof
from .PassphraseAck import PassphraseAck
from .PassphraseRequest import PassphraseRequest
from .PinMatrixAck import PinMatrixAck