0xMiden / 0xMiden/examples

Proposal: Add Merkle root example in MASM

Aperta
#232 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
21
Fork
28
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi team, I'd like to add a simple Merkle root calculation example to demonstrate tree structures for state proofs. It uses stack operations to simulate hashing pairs of leaves.

Example code sketch:
begin
# Leaf values (4 leaf, push ke stack)
push.1
push.2
push.3
push.4

# Level 1: Hash leaf pairs (simulasi hash dengan mul + add)
dup.1 dup.3 mul add # hash leaf 1 & 2
dup.1 dup.3 mul add # hash leaf 3 & 4

drop.4 # drop leaf asli

# Level 2: Hash node pairs (root)
dup.1 dup.1 mul add # hash node 1 & 2

drop.2 # drop node intermediate

# Hasil root di stack atas
end

This could help builders learn about Miden's Merkle Patricia Trees. Feedback?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.