intel sawtooth-mktplace (memo1)

memo1

https://github.com/hyperledger/hyperledger

Linux Foundation HyperLedgerのリポジトリに、
Intelが作ったSawtooth Lakeという名前のソフトウェアがあったので試してみた。

チュートリアル
http://intelledger.github.io/tutorial.html

ソースコードを見た時のメモ

main
https://github.com/IntelLedger/sawtooth-mktplace/blob/master/mktmain/client_cli.py#L1363

url = config['LedgerURL']

https://github.com/IntelLedger/sawtooth-mktplace/blob/master/mktplace/mktplace_client.py#L152

https://github.com/IntelLedger/sawtooth-mktplace/blob/master/mktplace/mktplace_communication.py#L117

sign

https://github.com/IntelLedger/sawtooth-mktplace/search?utf8=%E2%9C%93&q=sign_from_node

CBOR

https://intelledger.github.io/sawtooth_api/gossip.common.html

http://cbor.io/

TransactionMessage

sign_from_node()

https://github.com/IntelLedger/sawtooth-mktplace/blob/master/mktplace/mktplace_client.py#L122

        msg = market_place.MarketPlaceTransactionMessage()
        msg.Transaction = txn
        msg.SenderID = self.LocalNode.Identifier
        msg.sign_from_node(self.LocalNode)

MarketPlaceTransactionMessage

class MarketPlaceTransactionMessage(transaction_message.TransactionMessage):

https://intelledger.github.io/sawtooth_api/journal.messages.transaction_message.html

class TransactionMessage(message.Message):

https://intelledger.github.io/_modules/gossip/message.html#Message

from gossip.signed_object import SignedObject

https://intelledger.github.io/_modules/gossip/signed_object.html

    def sign_from_node(self, node):
        """Generates the signature from the signing key stored in a node.

        Args:
            node (Node): The node providing the signing key.
        """
        assert node.SigningKey
        return self.sign_object(node.SigningKey)
    def sign_object(self, signingkey):
        """Generates a string signature for the object using the signing
        key.

        Args:
            signingkey (str): hex encoded private key
        """

        serialized = self.serialize(signable=True)
        self.Signature = pybitcointools.ecdsa_sign(serialized, signingkey)

        if not self._verifyingkey:
            self._verifyingkey = get_verifying_key(serialized, self.Signature)
            self._originatorid = pybitcointools.pubtoaddr(self._verifyingkey)

        self._identifier = hashlib.sha256(self.Signature).hexdigest()

pybitcointools
ecdsa_sign

https://github.com/vbuterin/pybitcointools/blob/8e8a33d7281c871950519e5f256ad08cf0d5df69/bitcoin/main.py#L519

ecdsa sign

楕円曲線DSA - Wikipedia

Elliptic Curve Digital Signature Algorithm - Wikipedia, the free encyclopedia

validator

8080番ポート等で、HTTPリクエストを受け付ける箇所は、validatorという名前らしい。

https://github.com/IntelLedger/sawtooth-validator/blob/master/bin/txnvalidator

https://github.com/IntelLedger/sawtooth-validator/blob/master/txnserver/web_api.py#L322

https://github.com/IntelLedger/sawtooth-validator/blob/master/txnserver/web_api.py#L399
TCPポートを開いている。(LISTEN)