SlideShare a Scribd company logo
1 of 12
Download to read offline
Hash Tree
2015/11/10
0x64 Tales
#02 Data Structure
Livesense Inc.
HORINOUCHI Masato
Hash Tree ってなに?
概要
暗号理論および計算機科学において、ハッシュ木(Hash tree, ハッ
シュツリー)またはマークル木(Merkle tree)とは、より大きなデー
タ(例えばファイル)の要約結果を格納する木構造の一種であ
り、データの検証を行う際に使用される。
— ハッシュ木 - Wikipedia
要するに…
大きなデータを複数データブロック
に分割し、破損や改竄の検証処理に
利用できる。
動作原理
• 二分木
• リーフ
• データブロックのハッシュ値
• (内部)ノード
• 子ノードのハッシュ値を結合した結果のハッシュ値
デモ
元データ生成
$ dd if=/dev/urandom of=sample bs=1M count=4
$ split --bytes=1048576 --numeric=1 --suffix-length=1 sample L
$ ls -l
-rw-r--r-- 1 horinouchi horinouchi 1048576 Nov 10 18:37 L1
-rw-r--r-- 1 horinouchi horinouchi 1048576 Nov 10 18:37 L2
-rw-r--r-- 1 horinouchi horinouchi 1048576 Nov 10 18:37 L3
-rw-r--r-- 1 horinouchi horinouchi 1048576 Nov 10 18:37 L4
-rw-r--r-- 1 horinouchi horinouchi 4194304 Nov 10 18:34 sample
データ検証などで利用するMerkle Treeのメモ を参考にしました。
手作業
$ openssl dgst -sha256 -binary L1 > H00
$ openssl dgst -sha256 -binary L2 > H01
$ openssl dgst -sha256 -binary L3 > H10
$ openssl dgst -sha256 -binary L4 > H11
$ cat H00 H01 | openssl dgst -sha256 -binary > H0
$ cat H10 H11 | openssl dgst -sha256 -binary > H1
$ cat H0 H1 | openssl dgst -sha256 -binary > TOP
$ hexdump -C TOP
Ruby gem
$ gem install treehash
$ treehash sample
• Treehash
• とはいえ、この gem の中身は全く二分木使ってない…。
ZFS
• Data integrity (データ完全性)
• ディスクを直接書き換えてもブロック単位でチェックできる
よ。
• Copy-On-Write
• ブロック単位で更新箇所のみ write できるよ。
他の Hash Tree の利用
• P2P
• BitTorrent
• Bitcoin
• 分散VCS
• Git
ご清聴ありがとうございました

More Related Content

More from Masato HORINOUCHI (9)

Church Numerals
Church NumeralsChurch Numerals
Church Numerals
 
CPS & CTO
CPS & CTOCPS & CTO
CPS & CTO
 
FM synthesis
FM synthesisFM synthesis
FM synthesis
 
Inside mml2wav.rb
Inside mml2wav.rbInside mml2wav.rb
Inside mml2wav.rb
 
A440
A440A440
A440
 
Scheme Interpreter in Ruby
Scheme Interpreter in RubyScheme Interpreter in Ruby
Scheme Interpreter in Ruby
 
Clock / Timer
Clock / TimerClock / Timer
Clock / Timer
 
POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
 
Elixir紹介
Elixir紹介Elixir紹介
Elixir紹介
 

Recently uploaded

論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 

Recently uploaded (9)

論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 

Hash Tree