DEV Community

Cover image for อะไรคือ Derivation Path
Anuchit Prasertsang
Anuchit Prasertsang

Posted on

อะไรคือ Derivation Path

ในโลกของคริปโตแนวคิดการใช้ wallet (กระเป๋าตังค์)อาจะสร้างความมึนงงให้ใครหลายคนได้ เพราะเราสามารถสร้าง

  • Private Key หรือ keystore file กุญแจส่วนตัวที่ถูกป้องกันด้วยพาสเวิร์ด
  • mnemonic phrase คือชุดของคำ ที่สามารถทำให้เข้าถึง private key หลายๆตัวได้

สิ่งที่แตกต่างอีกอย่างคือ

  • หนึ่งบัญชีจะมีแค่หนึ่ง Private Key หรือ keystore file เท่านั้น
  • การสร้าง mnemonic phrase สามารถทำให้เราควมคุมและเข้าถึงหลายๆบัญชีได้ด้วย mnemonic phrase อันเดียว

ทำไม phrase อันเดียวถึงสร้างได้มากกว่า 1 บัญชี

mnemonic phrase — หรือที่เรียกกันว่า “Hierarchical Deterministic Wallet” จะสร้างบัญชีโดยการใช้ phrase รวมกับ derivation path เพื่อสร้างบัญชี โดยใช้วิธีทางคณิตศาสตร์อันซับซ้อนที่เรียกกันว่า cryptography

อะไรคือ derivation path

โดยนิยาม derive คือ “to obtain something from a specified source.” ในบริบทของคณิตศาสตร์คือ “To obtain [a function or equation] from another by a sequence of logical steps, for example by differentiation.” อ่านแล้วงงๆ

พูดให้ง่ายคือ
กระเป๋าหนึ่งใบสามารถมีช่องใส่ของได้หลายๆช่อง การแบ่งออกเป็นช่องย่อยๆ คือ derivation path ถึงจะแบ่งออกเป็นช่องๆย่อยๆ แต่ละช่องก็อยู่ในกระเป๋าใบเดียวกันเหมือนเดิม

พูดให้ยากคือ
หน้าตาของ derivation path
m/44'/501'/0'/0'/0

ตัวเลขแต่ละตัวบอกว่า private key, public key และ ที่อยู่ของช่องย่อยและการเปลี่ยนแปลงอยู่ตรงไหน อ่านเพิ่ม ถ้าอยากได้กระเป๋าเพิ่มจาก phrase เดิมก็เพิ่มตัวเลขหลังสุดไปเรื่อย

Address #1: m/44'/501'/0'/0'/0
Address #2: m/44'/501'/0'/0'/1
Address #3: m/44'/501'/0'/0'/2

Address #99: m/44'/501'/0'/0'/98

ด้วยเวทย์มนต์ทางคณิตศาสตร์เลยทำให้เราสามารถ แบ่งกระเป๋าเงินเราเป็นกระเป๋าย่อยๆ โดยเริ่มต้นจาก mnemonic phrase อย่างงดงาม

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay