Git Product home page Git Product logo

Comments (6)

shohu avatar shohu commented on August 29, 2024

所有権移転のtransactionが、buyer, sellerの2人の署名があれば実行できるようにしたい

from estate-sample.

shohu avatar shohu commented on August 29, 2024

transactionのsender取得方法

estateの所有者とtransaction実行者が一致すればOKとする条件で色々できるかも。

Does Hyperledger-Fabric provide a way to find out who (msg.sender in Ethereum) called the chaincode?

これをみると、GetCreatorというメソッドで取得できる?
以下がそう。
https://fabric-shim.github.io/master/fabric-shim.ChaincodeStub.html#getCreator__anchor

from estate-sample.

shohu avatar shohu commented on August 29, 2024

以下対応を検討してみる。

IMG_1906

構造

売買申請データ

  • estate category
  • estate code
  • from creator id (申請者のcreator id
  • to creator id (承諾側のcreator id
  • amount (購入価格
  • status (APPLY, ACCEPT, CANCEL)

メソッド

  • apply
     買付する際に使う。from creator id と tx実行者が一致しなければいけない
  • accept
     買付を承諾する際に使う。to creator id と tx実行者が一致しなければいけない
     承諾すると、Estateに履歴を刻む

課題

  • apply メソッド投げる際に 売買申請データ を作る必要があるが、申請者、承諾側のcreator id はメソッドか何かでわかる?
  • 代理で第三者がtxなげる場合に、txの実行者を見てても良いか?

from estate-sample.

shohu avatar shohu commented on August 29, 2024

GetCreatorでcreator id取得試す

以下をみると ProposalCreator で返却される。

getCreator()
Returns the identity object of the chaincode invocation's submitter
Returns:
Type
ProposalCreator

https://fabric-shim.github.io/master/fabric-shim.ChaincodeStub.html#getCreator__anchor

ただ、ProposalCreator をみると mspid しか持っておらず
https://fabric-shim.github.io/master/fabric-shim.ProposalCreator.html#ProposalCreator__anchor

Membership Service Providerインスタンスの一意のID

らしいので、これ現状だと使えない・・・?
mspidは以下だよなぁ

name: first-network-org1
version: 1.0.0
client:
  organization: Org1
  connection:
    timeout:
      peer:
        endorser: '300'
organizations:
  Org1:
    mspid: Org1MSP

ただ、以下のような形で username指定しているから、contract実行時にとれそうだけどな、ユーザー情報

    const userName = '[email protected]';

    // Load connection profile; will be used to locate a gateway
    let connectionProfile = yaml.safeLoad(
      fs.readFileSync('./gateway/networkConnection.yaml', 'utf8')
    );

    // Set connection options; identity and wallet
    let connectionOptions = {
      identity: userName,
      wallet: wallet,
      discovery: { enabled: false, asLocalhost: true }
    };

    // Connect to gateway using application specified parameters
    console.log('Connect to Fabric gateway.');

    await gateway.connect(connectionProfile, connectionOptions);

ClientIdentity

これがどこかで取得できればいけそうだ
https://fabric-shim.github.io/master/fabric-shim.ClientIdentity.html#getID__anchor

以下で権限チェックしている。この辺り使えそう

const ClientIdentity = require('fabric-shim').ClientIdentity;

let cid = new ClientIdentity(stub); // "stub" is the ChaincodeStub object passed to Init() and Invoke() methods
if (cid.assertAttributeValue('hf.role', 'auditor')) {
   // proceed to carry out auditing
}

User id っぽいものが取れた

contractで以下

    async clientId(ctx) {
        let cid = new ClientIdentity(ctx.stub);
        return JSON.stringify(cid.getID());
    }

出力した文字列が以下。[email protected]を一旦見ておけばいいかな。

"\"x509::/C=US/ST=California/L=San Francisco/[email protected]::/C=US/ST=California/L=San Francisco/O=org1.example.com/CN=ca.org1.example.com\""

from estate-sample.

shohu avatar shohu commented on August 29, 2024

ただ、こちらの方法だといずれにしろ秘密鍵がサーバーに残ってしまうため、なるべくclientで管理させたい。

このため、client側で秘密鍵を生成して、それで サーバー側では秘密鍵を扱わずにする
形の方がよいかもしれない。

from estate-sample.

shohu avatar shohu commented on August 29, 2024

そもそも、commercial-paperのwalletは既存にあった wallet を使っている。
ということは、これをbrowser側でwalletを作成してそのファイル達を使って、transactionが送信できれば一番良い。

browser側で ca認証局とやりとりをして、ローカル秘密鍵保存。
そのwalletを元に、server側とやりとりをする。

from estate-sample.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.