HackMD
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Welcome to cypherspace! Here's your hypercore! === ## About this documentation This is an FAQ and guide to USING hypercore as a developer. It's not focused on the internals of hypercore. ## What is hypercore? Hypercore is: * An append only log, like an array of values which can only grow forever, * writable by one device, * easily replicatable to other devices in full or in part, * with signatures and hashes to prevent tampering of the data, allowing it to pass through untrusted peers along the way. Hypercore is not: * editable _(but it can be implemented at the application level by adding "delete" messages to the log)_ * writable by more than one peer/device _(but you can get this by bundling together one hypercore from each writer with some logic on top. See [multifeed](https://github.com/noffle/multifeed) and [hyperdb](https://github.com/mafintosh/hyperdb))_ You can use it as: * a base to build distributed applications on top of ## (Other docs) https://github.com/mafintosh/hypercore https://dat-dev-story.hashbase.io/hypercore/basic-usage.html Overview of the many small modules related to dat and hypercore: https://dat-dev-story.hashbase.io/extra-guides/breakdown.html https://datprotocol.github.io/book/ https://github.com/lachenmayer/hyperdb-authorization-guide https://dissecting-dat-lachenmayer.hashbase.io/ https://github.com/noffle/kappa-arch-workshop ## Where can I run hypercore? * node (which storage libraries can you use?) * browser (any limitations to replication or storage? which storage libraries are there?) * Beaker - what APIs does it expose, maybe only "dat" aka hyperdrive, and some swarm library? * non-javascript implementations * [rust](https://github.com/datrs/hypercore) * special notes about compiling leveldb and the crypto library? which version of node works best for that? * extra credit: tricks to get it running on ARM devices, android, iOS, raspi? ## What kind of data can you put in a hypercore? What's the data model? * Apparently you can access the log by item index using `createReadStreamn` or by overall byte offset (for all items together) using `seek`? * What data can go in each item of the log? Are they binary buffers or JSON objects? `valueEncoding` ? * One writer device, multiple readers. (What happens if you try to write from multiple devices by sharing a key? Do you fork it and break it like SSB?) * Append only, grows forever, no deletion? Though sparse mode helps work around this. * Can you discard its history? What about breakpoints for history? (I'll sync starting from version xxx) * ^^^ you can use [feed.clear()](https://www.npmjs.com/package/hypercore#feedclearstart-end-callback) to discard records from a hypercore you have on your device, but the meta-data about the record cannot be discarded. * Is it good for large files? What about lots of very small updates? Practical scaling limits? It is awesome for large data sets because you can use sparse replication mode and `feed.clear()` to retain only what is needed for processing. * Hash, crypto properties? * Each hypercore has a public/private keypair which can do several things. * The public key is like the address of the hypercore, and the private key gives you the ability to write to it (from a single device). * A. The discovery key is derived from the public key, so you can find peers in a DHT without divulging the public key * B. The private key is used to sign writes, proving that they were made by the owner of the hypercore * C. At the application level you could for example implement private messages between users by encrypting things to the public key of someone's hypercore (and publishing it in your own hypercore of outgoing messages). That person is the only one with the private key to read your message. * What else do we need to know about hashes and signatures? * How do you refer to a specific message in a hypercore? You could say HYPERCOREHASH@SEQNUMBER - is there a hash-based way to do it which is safer? * https://github.com/mafintosh/hypercore-strong-link * noffle says: "hypercore already stores the hash of each message! Except it's more complicated than a regular content hash (it contains leaf vs internal node info and the length), and there's no public API for it yet." ## What other things are built on top of hypercore? * [Hyperdrive](https://github.com/mafintosh/hyperdrive#hyperdb-backend) - filesystem type datastructure. Used to be on top of hypercore directly, but maybe now will be on top of hyperdb? * [dat](https://github.com/datproject/dat) - is a friendly branding for hyperdrive w/ a specific setup for swarm replication? * [Hyperdb](https://github.com/mafintosh/hyperdb) - kv store with multiple writers, who all have full permissions to write (once they have been [authorized](https://github.com/lachenmayer/hyperdb-authorization-guide)). * [multifeed](https://github.com/noffle/multifeed) / [kappa-core](https://github.com/kappa-db/kappa-core) / [cabal](https://github.com/cabal-club/cabal) - collection of hypercores with indexes and views on top, similar to SSB's views ## How do you replicate (sync) w/ others? What swarm libraries are there? * Does each hyperdrive have its own unique crypto key? And the discovery key is derived from that? * hypercore might have a header that you can use to specify versions to allow you to reject incompatible peers? Or iss there another sidechannel you can use during replication for your own application purposes like authorization to join the swarm, version checking, etc? * Swarm libraries: * discovery-swarm includes 3 strategies * mDNS (bonjour)? * DHT (like bittorrent trackers)? * DNS (using a special DNS server hosted by mafintosh)? * hyperswarm * next-gen version of discovery-swarm * does NAT hole-punching * https://github.com/hyperswarm/network * https://pfrazee.hashbase.io/blog/hyperswarm * https://www.npmjs.com/package/consent-swarm * https://github.com/mafintosh/webrtc-swarm * https://github.com/geut/discovery-swarm-webrtc * Which of those swarm libraries do NAT holepunching? * How are replication responsibilities divided between the swarm library, hypercore, and something like multifeed? * How many peers can be in a swarm? * [256 peers is the default](https://github.com/mafintosh/hypercore-protocol/blob/master/index.js#L112-L115) but you can pass in `opts.maxFeeds` to increase that. * When you replicate several hypercores at once are they handled together for efficiency, or are they totally independent? What order does it replicate the feeds (one whole feed at a time, or in parallel?) * What if you wanted to pipe two hypercores together by hand across your own transport, like websockets, or sneakernet? * How did [dat-shopping-list](https://github.com/jimpick/dat-shopping-list) work? It hosted a single swarm peer on a server and multiplexed that connection down to web clients by websockets? * How do you know when your hypercore is completely replicated to someone else? * It's possible but tricky; see [this GitHub issue](https://github.com/mafintosh/hypercore/issues/179) ## What is sparse mode? Why, when, and how to use it? * How to only get certain files? * How to drop those files to reclaim space? * What crypto protections do you lose in sparse mode? Can you still verify signatures? In [the SLEEP format docs](https://github.com/datproject/docs/blob/master/papers/sleep.md) it says after each write you sign the combined roots of the Merkle tree(s) -- seems like to verify those you would need all the data up to that point? * Rumour: hypercore writes data in "sparse files" but OSX at least doesn't support those, so it takes up all the disk space of a whole hypercore just to download one file. Is this true? There's some kind of "random access pagefile" module you can use as hypercore's storage that fixes this? I think this came up in the context of Beaker Browser - cinnamon ## What is live mode vs static mode? Why and when to use them? ## API usage examples * Lifecycle of a hypercore * https://github.com/mafintosh/hypercore-protocol/ * Creating from scratch * Creating with a given key * Ready. What things have to wait until it's ready? * Closing. What are the rules around closing? * Writing * Are there batch writes to append multiple items atomically? * Are individual item writes atomic? * Writing using a stream. (Any special rules about closing the stream?) * Writing a single item * Reading * Random access reads on demand, by item index * Random access reads on demand, by overall byte offset * Listening to a stream of changes as they arrive - downloading on demand or not; waiting for new changes or not; any special rules about closing the stream? * Peer status, number of peers * Crypto and security * https://github.com/mafintosh/hypercore-crypto/ * Verifying signatures and hashes * Encrypting and decrypting messages to/from a specific hypercore's key, for sending private messages to that peer * Syncing / replication * Are incoming items added atomically or can they be incomplete (only some of the bytes)? If atomic, does that mean very large items can't be downloaded incrementally, stopped, and resumed? * Sparse mode * Knowing if an item is there yet or not * Requesting an item if it's not there yet * Making an item go away from your local copy if you don't need it - is this possible? I see `undownload` but that cancels a pending download, doesn't remove data from disk * Live mode vs static mode What other API calls are there? ## How to debug and explore a hypercore? * Is there a command line utility to print out the contents of a hypercore? * https://noffle.github.io/kappa-arch-workshop/build/04.html

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully