DimensionDev / Maskbook-Talks

Where talks of Maskbook happen.
7 stars 1 forks source link

Arweave Integration Brainstorming #36

Closed neruthes closed 3 years ago

neruthes commented 4 years ago
Main Issue Documentation
https://github.com/DimensionDev/Maskbook/issues/1057 https://confluence.dimension.chat/x/3IEf
neruthes commented 4 years ago

Attachment Service

Introduction

Maskbook Post can employ Arweave to support publishing attachments.

Steps

Publishing

Viewing

septs commented 4 years ago

Redefinition Wallet feature set:

Basic feature set

  1. show name (settable)
  2. show wallet logo (or coin icon?)
  3. show wallet address
  4. show current balance
  5. show private key
  6. transaction history (basic fields)
  7. remove this wallet

Extended feature set

  1. transfer balance 1.1. Send AR for Arweave 1.2. Send Red Packet for Ethereum
  2. transaction history (more fields)
  3. provider specific feature set
neruthes commented 4 years ago

Moderate Issue:

Arweave does not distinguish MetadataPreviewPage and DirectDownloadUrl. It is difficult to allow arbitrary binary attachments.

septs commented 4 years ago

Arweave metadata in tags

septs commented 4 years ago

Predefinition Tags

Content-Type: [mime type]
User-Agent: Maskbook/[version]
X-Action: [action format definiton]
X-Hint: [hint text]

action format definition (URN based)

# attachement
user-action:com.maskbook:1:plugin.org.arweave:1:attachment:1
# masbkook backup with encrypted (archived)
user-action:com.maskbook:1:plugin.org.arweave:1:maskbook-backup:1
Jack-Works commented 4 years ago

I found you two are inventing strange standard 🤔

neruthes commented 4 years ago

Join the brainstorming and offer your ideas please 🎉

septs commented 4 years ago

sample application/pdf: https://arweave.net/d_6yFXJGH52rYID8H9-ettLqe-Lknv4YQOWpu3wXGVw https://viewblock.io/arweave/tx/d_6yFXJGH52rYID8H9-ettLqe-Lknv4YQOWpu3wXGVw

sample audio/mp3: https://arweave.net/Lf-cEVOMqUCDoPqyp2H594YxIGkrN5Ih-CAGwsyVmLY https://viewblock.io/arweave/tx/Lf-cEVOMqUCDoPqyp2H594YxIGkrN5Ih-CAGwsyVmLY

septs commented 4 years ago

Related: https://github.com/DimensionDev/Maskbook/issues/1131 https://github.com/ArweaveTeam/arweave/issues/240

neruthes commented 4 years ago

Related: DimensionDev/Maskbook#1131 ArweaveTeam/arweave#240

15 confirmations... How long does it usually take? 🤔

septs commented 4 years ago

Related: DimensionDev/Maskbook#1131 ArweaveTeam/arweave#240

15 confirmations... How long does it usually take? 🤔

12 confirmations at 10 MiB blob ≈ 10 minutes This result is NOT CREDIBLE (i need to repeated observe)

septs commented 4 years ago

arweave network has many small blob (not more then 1 MiB transaction) (for webpage archive, maybe is official browser extension designed usage?)

yisiliu commented 4 years ago

We don't really need to focus on the web page archiving at first. All we need is to support 0-15MB file uploading onto arweave network directly from our extension.

neruthes commented 4 years ago

Plugin: Feature: File Manager

Proposed by @OiCkilL. We want to include a file manager in the plugin.

A user can:

neruthes commented 4 years ago

Wallet: Feature: WalletType-Specific Transaction History Interpretation

Coverage

Changes

These views should be able to render rich content for the wallet type.

neruthes commented 4 years ago

UI Wireframe: Upload Attachment When Composing Post

IMG_2320

neruthes commented 4 years ago

UI Wireframe: Plugin Main View (Not For Stage 1)

IMG_2321

neruthes commented 4 years ago

Proposal: Move Arweave Wallet Into Arweave Plugin

Proposed by @OiCkilL.

We previously wanted to add Arweave to the list of supported wallet types. However, it is possible that the Arweave wallet can exist inside the Arwaeve plugin, since its third-party applications (within Maskbook) will remain rare in the upcoming future.

We can greatly reduce technical complexity if we let the Arweave plugin manage the Arweave wallet. No need to hurry on designing wallet operation request API, etc.

However, this proposal comes with certain challenges.

Challenge 1: Plugin Deletion & Data Lifecycle

Although we are not going to really implement plugin deletion feature right now, it is necessary to inspect the meaning of deletion. If the user deletes the Arweave plugin, shall the Arweave wallet remain in the Maskbook database? The answer seems to be false.

We can have a safer data lifecycle, like the idea employed by Dropbox. Apps can store their data in Dropbox, and the data is not deleted upon uninstallation, and the user will be able to purge junk data manually in the Dropbox storage management panel. This kind of data management could be a bit overkill for Maskbook.

Minimally, we may have a "Purge remaining data of deleted plugins" button.

Challenge 2: Cognitive Inconsistency

It may have been well recognized that all Wallets should be managed by Maskbook instead of the Red Packet plugin. If now the Arweave wallet is managed in the Arweave plugin, a user may be confused.

It remains uncertain whether this is a big matter, but we have to be prepared.

We previously discussed the idea of wallet virtualization (similar to #40). Maskbook can include a Virtual Wallet in the list of Wallets in the Wallets tab in Dashboard. When the user tries to make some operation, it is actually the plugin which handles the requests of the user, instead of native Maskbook wallet operation panel. However, this will make it harder to understand where a wallet is actually stored. Some text explanation can help, but uncertainty remains.

neruthes commented 4 years ago

Discussion Summary

Arweave Wallet Keygen can be complicated. My wish is that the keygen can happen inside Maskbook and the user can skip Arweave official website for this process. Otherwise, the steps will be too frustrating for a normal Maskbook user who merely wants to upload an attachment.

And @yisiliu confirmed that it will be possible that an Arweave wallet generated in Maskbook will get free file uploading eligibility per our agreement with Arweave.

It may be a good choice to keep keygen automated and within Maskbook.

neruthes commented 4 years ago

Note

Since the major purpose is to upload encrypted attachments, we will not be able to employ the native HTTPS online distribution service of Arweave official website.

This imposes several design restrictions:

When designing the file-viewing experience, Maskbook should not open arweave.net. Instead, Maskbook shall open a in-the-extension webpage which is managed by Maskbook where necessary parameters are passed. For example, chrome-extension://nbajgjnadncebloipcedoannhljjkiel/plugin/com.maskbook.provide.net.arweave/encryptedFile.html?id=dUf-7lbHbfbND32xOgqBsmKxqSwcLguXWa0ZOBOYmK0&postKey=12345678.

neruthes commented 4 years ago

Note

Although Arweave offers high flexibility for file size, it may be good to have a file-size limit. If the file is too large, the usability of the attachment service will be in danger.

My proposal is that the limit should be 20 MB. Looking forward to seeing proposals for other numbers.

yisiliu commented 4 years ago

I proposed 15MB but 20 should be fine too. Another purpose of this is to later upload user's encrypted posts onto the Arweave network and provide them a dashboard for them to view.

neruthes commented 4 years ago

Proposal: Independent FileKey

In the long run, we want to have a comprehensive access control strategy and reading the PostKey of a Post can be considered dangerous. It may be necessary to prevent the Arweave plugin from accessing the PostKey of a Post.

With this in mind, it might be a good idea to split the PostKey and the FileKey. The FileKey is used to encrypt the file and it is put in the Post payload as a field of plugin-specific private metadata.

This will allow the Arweave plugin to better manage the list of files without endangering the confidentiality of PostKeys.

neruthes commented 4 years ago

Note

I just summarized recent fruits of discussions into the documentation. Looking forward to feedbacks.

neruthes commented 4 years ago

Discussion Summary

neruthes commented 4 years ago

Note: Blockchain-Based Attachment Blob Data Structure (Overall)

Encrypted Blockchain-Based Attachment Description

Mounting Point:

Data Fields:

Blockchain-Based Attachment Binary Blob

Data Fields:

Binary Serialization:

// To be designed by @septs.

septs commented 4 years ago

Attachment Blob Magic header:

MASKBOOK-ATTACHMENT as ASCII encoding

to identify maskbook attachment blob file

septs commented 4 years ago

@yisiliu apply https://msgpack.org to maskbook attachment blob format OR design your own binary layout?

yisiliu commented 4 years ago

apply https://msgpack.org to maskbook attachment blob format

Actually in the design of ntge, we are also considering moving to msgpack so yes go ahead with it.

neruthes commented 4 years ago

Discussion Summary

Proposed by @yisiliu.

The FileKeyHash field should be removed from on-chain payloads.

neruthes commented 4 years ago

Discussion Summary

Proposed by @septs.

The file limit should start at 1 MB and we can raise it gradually according to the feedbacks from the users.

neruthes commented 4 years ago

Discussion Summary: Upload clearfile attachment without encryption

It can be a common scenario where a user merely wants to take advantage of the attachment feature of Maskbook without encrypting the file.

Interaction Design

We can have a checkbox to toggle off "Encrypted Attachment" or another button "Upload Without Encryption". The user can use this to access the basic file uploading feature of Arweave.

Data Structure

The returned data from the "Attachment by Arweave" plugin (Plugin-Specific Post Metadata) should contain 2 fields:

If the file is encrypted, the EncryptedFileDescription should be a valid Encrypted Blockchain-Based Attachment Description object (as defined above), and the ClearFileDescription should be null.

If the file is unencrypted, the ClearFileDescription should be a string of Arweave Transaction ID, and the EncryptedFileDescription should be null.

Error Handling

yisiliu commented 4 years ago

Due to the limit of the expected confirmation time to be ~15-20 minutes, users cannot retrieve the data in that waiting time, which would cause user's misunderstanding of our production. I've received some suggestions on how to improve this experience and here is the proposal:

Let's maintain a cache server to hold the file for the users temporarily and set the lifetime of these temps as 30 minutes. Each time a user would like to access a file, Maskbook would first query arweave.net/ID. If it doesn't work, then Maskbook would query maskbook.com/temp/ID to access it as a temporary solution.

What do you guys think?

neruthes commented 4 years ago

Let's maintain a cache server to hold the file for the users temporarily and set the lifetime of these temps as 30 minutes. Each time a user would like to access a file, Maskbook would first query arweave.net/ID. If it doesn't work, then Maskbook would query maskbook.com/temp/ID to access it as a temporary solution.

A good way to enhance user experience, indeed. I would like to suggest using domain name arweave.net.provide.maskbook.com, to conform to the package name of the plugin, com.maskbook.provide.net.arweave.

neruthes commented 4 years ago

Discussion Summary: Image Preview

For images, the plugin can store a small preview image (e.g. 20*20px) upon uploading or upon downloading. When browsing the list of files, if the preview image can be found in the local database, the preview image shall replace the file type icon.

The preview images shall not be included when exporting plugin data or creating Maskbook database backup.

neruthes commented 4 years ago

Discussion Summary: Go to Post

When browsing the list of files, the user should be able to jump the URL of the Post which contained the attachment, if the file is from a Post.

When witnessing a Post which contains Plugin-Specific Post Metadata for "Attachment by Arweave" plugin, the plugin is notified. Upon notification, if the TransactionId is not associated with a PostLocator, the plugin shall record an event to associate the PostLocator with the TransactionId.

File browsing is not included in Stage 1.

neruthes commented 4 years ago

Discussion Summary: Dashboard Plugin Panel

The Plugin panel in Dashboard is not included in Stage 1.

septs commented 4 years ago

@neruthes

  1. Require a MIME Type for Content Type (Encrypted payload)
Content-Type: application/x.dimensiondev+encrypted-v1

Reference: https://en.wikipedia.org/wiki/Media_type#Registration_trees

  1. Raw file
    1. Prefer original MIME Type
    2. Use application/octet-stream when don't know data type
yisiliu commented 4 years ago

Looks good

neruthes commented 4 years ago

Idea: Reuse Landing Page

We can reuse the same landing page for all these files since the only varying element in the landing page would be the File Key, which can be easily passed to the landing page by location.search or location.hash.

Additionally, if we can solve cross-origin problems, the landing page can be editable, allowing better revamping and debugging.

Certain metadata should be passed to the landing page from the Plugin "Attachment by Arweave":

Pros

Cons

neruthes commented 4 years ago

Question

Should it be prohibited that sharing the landing page URL can result in allowing the recipient to decrypt the file?

septs commented 4 years ago

Roadmap