Files
hakorune/private_test/zkp_tutorial_demo.nyash
Moe Charm 4b984d937b refactor: MIR builder - extract expressions module (Phase 3-5)
- Moved all expression-related functions to expressions.rs (621 lines)
- Includes: build_expression, build_literal, binary/unary ops
- Added missing functions for build_expression completeness:
  - build_assignment, build_field_assignment
  - build_new_expression, build_await_expression
- expressions.rs now contains 16 functions total
- Build verified successfully
2025-08-25 18:15:23 +09:00

71 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Midnight Network ZKPチュートリアル - Nyashデモ
// ゼロ知識証明を視覚的に理解する
static box Main {
main() {
local tutorial = new ZKPTutorial()
tutorial.start()
}
}
box ZKPTutorial {
init { console }
constructor() {
me.console = new ConsoleBox()
}
start() {
me.console.log("🔐 ゼロ知識証明チュートリアル by Nyash")
me.console.log("=====================================")
// レッスン1: 年齢証明
me.ageProofDemo()
// レッスン2: 秘密投票
me.votingDemo()
// レッスン3: 残高証明
me.balanceProofDemo()
}
ageProofDemo() {
me.console.log("\n📝 レッスン1: 年齢証明")
me.console.log("実際の年齢を明かさずに「18歳以上」を証明します")
local alice = new Person("Alice", 25)
local proof = alice.proveAgeAbove(18)
me.console.log("Aliceの証明: " + proof)
me.console.log("検証結果: 18歳以上 ✅")
me.console.log("実際の年齢: 秘密のまま 🤫")
}
votingDemo() {
me.console.log("\n🗳 レッスン2: 秘密投票")
// 投票内容を秘密にしながら有効性を証明
}
balanceProofDemo() {
me.console.log("\n💰 レッスン3: 残高証明")
// 具体的な金額を明かさずに「十分な残高がある」を証明
}
}
box Person {
init { name, age }
constructor(name, age) {
me.name = name
me.age = age
}
proveAgeAbove(minAge) {
// 実際のMidnightではZKP生成
// デモ用の簡易実装
if me.age >= minAge {
return "VALID_PROOF_" + new RandomBox().randomString(16)
}
return "INVALID_PROOF"
}
}