본문 바로가기
프로그래밍/Block Chain

[Block Chain] IPFS 프로토콜 정리

by YuminK 2023. 11. 19.

InterPlanetary File System는 분산 파일 시스템에 데이터를 저장하고 공유하기 위한 프로토콜, 하이퍼미디어, 파일 공유 P2P 네트워크이다. IPFS는 콘텐트 어드레싱을 사용하여 IPFS 호스트에 연결하는 전역 이름공간의 개별 파일을 고유하게 식별한다. (위키백과)

 

What is IPFS

IPFS is a modular suite of protocols for organizing and transferring data, designed from the ground up with the principles of content addressing and peer-to-peer networking. Because IPFS is open-source, there are multiple implementations of IPFS. While IPFS has more than one use case, its main use case is for publishing data (files, directories, websites, etc.) in a decentralised fashion.

 

Defining IPFS

The term IPFS can refer to multiple concepts:

  • A decentralized network composed of IPFS nodes that is open and participatory.
  • A modular suite of protocols and standards for organizing and transferring content-addressed data.

What IPFS isn't

While IPFS shares similarities with, and is often used in architectures with the systems described below, IPFS is not:

  • storage provider: While there are storage providers built with IPFS support (typically known as pinning services), IPFS itself is a protocol, not a provider.
  • A cloud service provider: IPFS can be deployed on and complement cloud infrastructure, but it in of itself is not a cloud service provider.

IPFS and the problems it solves

Verifiability

IPFS uses cryptographic hashes to verify the authenticity and integrity of files, making it difficult for malicious actors to tamper with or delete files.

 

Resilience

IPFS has no single point of failure, and users do not need to trust each other. In other words, the failure of a single or even multiple nodes in the network does not affect the functioning of the entire network, and an IPFS node can fetch data from the network as long as at least one other node in the network has that data, regardless of its location.

 

Centralization

IPFS is an open, distributed and participatory network that reduces data silos from centralized servers, making IPFS more resilient than traditional systems. No single entity or person controls, manages or owns IPFS; rather, it is a community-maintained project with multiple implementations of the protocol, multiple tools and apps leveraging that protocol, and multiple users and organizations contributing to its design and development.

 

Performance

IPFS provides faster access to data by enabling it to be replicated to and retrieved from multiple locations, and allowing users to access data from the nearest location using content addressing instead of location-based addressing. In other words, because data can be addressed based on its contents, a node on the network can fetch that data from any other node in the network that has the data; thus, performance issues like latency are reduced.

 

Link rot

IPFS eliminates the problem of link rot by allowing data to be addressed by its content, rather than by its location. So, in other words, content in IPFS is still reachable regardless of its location, and does not depend on specific servers being available.

 

Data sovereignty

IPFS protects data sovereignty by enabling users to store and access data directly on a decentralized network of nodes, rather than centralized, third-party servers. This eliminates the need for intermediaries to control and manage data, giving users full control and ownership over their data.

 

Off-chain storage

IPFS enables verifiable off-chain storage by creating a link between blockchain state and content-addressed published to IPFS. This works by storing a Content IDentifier (CID) (explained in How IPFS works) in a smart contract.

 

Local-first software

IPFS benefits local-first software by providing a performant, decentralized, peer-to-peer data addressing, routing, and transfer protocol that prioritizes data storage and processing on individual devices. With IPFS, data can be stored, verified and processed locally, and then synchronized and shared with other IPFS nodes when a network connection is available.

 

Vendor lock-in

IPFS prevents vendor lock-in , as users have sovereignty over their data and infrastructure. This is enabled by content-addressing, which decouples the data from a single location or infrastructure provider. Unlike traditional cloud vendors, IPFS enables you to change data storage locations without changing things like APIs and data management. In addition, because IPFS is open-source, community-maintained and modular, users are not obligated to use a particular subsystem (described in How IPFS works). Instead, users can customize IPFS for their preferred technologies, needs and values.

 

https://docs.ipfs.tech/concepts/how-ipfs-works/#how-ipfs-works

다양한 서브시스템들이 있는데, 각각 용도에 맞추어 사용하는 모듈이 다르다. 비트스왑, delegated routing, cid 등을 설명한다. 

 

https://docs.ipfs.tech/concepts/lifecycle/#_1-content-addressable-representation

IPFS 데이터 사이클

 

데이터를 청크하여 작은 블록들로 만들고 머클 dag을 만든다. 이후 pinning 과정을 거쳐 cid를 노드에 저장하는데 단순히 저장하는 것을 끝나진 않고, 서버 IP와 연결된 CID를 갖고 CID가 IPFS 네트워크상 찾아질 수 있도록 advertising 과정을 거친다. 

 

검색할 때는 컨텐츠를 찾고(상황별로 사용하는 방식이 다름) 머클댁 블록 정보를 가져와서 hash 검증하고 파일을 만들거나 접근할 수 있도록 한다. 삭제는 항상 로컬 노드의 동작이다. 다른 노드에서는 삭제되지 앟는다. 

 

https://docs.ipfs.tech/concepts/hashing/

해싱에 대해서

 

https://docs.ipfs.tech/concepts/immutability/

가리키는 컨텐츠에 변경이 일어나는 경우 CID값도 변경된다. 따라서 이를 유용하게 다루기 위해 IPNS 시스템을 이용하여 새로 만들어진 CID를 관리하도록 한다. (DNS 처럼 이름으로 접근하되, 실제 주소는 바뀌어 있다)

 

https://docs.ipfs.tech/concepts/persistence/#persistence-versus-permanence

데이터를 영구히 안전하게 저장하는 것. Ipfs 네트워크는 자동으로 리소스를 캐싱하며 다른 노드들에게 제공한다. 이는 노드가 캐싱을 하고 공유할 의사가 있는지에 따라 달라진다. 저장소는 유한하기에 노드는 이전에 캐싱된 리소스를 지울 필요가 있다. 이러한 과정을 가비지 컬렉션이라 부른다. 이러한 과정을 막기 위해 피닝을 사용한다. 직접 피닝할 수도 있고 피닝 서비스를 제공하는 업체에 맡기는 것도 가능하다. 

 

파일 코인 서비스를 사용하여, 클라우드? 서비스 같은 느낌으로 쓸 수 있다고 말하는 듯. 아무래도 특정 노드가 해당 데이터를 가지고 있어야 사라지지 않고 접근할 수 있을 테니, 이런 처리를 돈 받고 대여? 해주는 시스템으로 보인다. 근데 해당 서비스 제공자가 사업을 닫으면 문제가 된다. (AWS가 사업을 접는다면 … 이런 느낌인가..?)

 

https://docs.ipfs.tech/concepts/privacy-and-encryption/#content-identifiers

노드를 찾는 과정은 DHT를 통해 이루어지며 레거시 웹 서비스보다 빠르게 정보를 찾아올 수 있다. 그러나 이러한 쿼리는 public 환경에서 발생한다. 트래픽이 외부에서 보여지는 것이다. 노드의 주소(peerID)는 DHT를 통해 찾아질 수 있다. 어떤 정보를 요청하고 있고 제공하는지 모니터링 될 수 있다. 

 

IPFS는 컨텐츠 보안이 아닌 전송 보안을 사용하여 다른 노드로 데이터가 보내질 때 안전하다. 그러나 CID정보를 가진 경우에는 해당 데이터를 볼 수 있다. 컨텐츠 보안은 처리되지 않았으며, 프로젝트에 따라 사용자에게 맡긴다. 

 

https://docs.ipfs.tech/how-to/desktop-app/

데스크탑 튜토리얼, ipfs 네트워크에 파일을 올리고 cid값으로 데이터를 노드에 받아오는 과정을 다루고 있다. 

댓글