Pure MoonBit, zero-FFI IETF modern privacy-authentication & threshold cryptography stack: RFC 9497 (OPRF/VOPRF/POPRF), RFC 9578 (Privacy Pass), RFC 9807 (OPAQUE-3DH), RFC 9591 (FROST + Pedersen DKG), RFC 9380 (Hash-to-Curve), RFC 9496 (Ristretto255), and RFC 7748 (X25519) over a single zero-duplication cryptographic core.
在单一零重复底层密码底座之上完整构建 RFC 9497(OPRF / VOPRF / POPRF)+ RFC 9578(Privacy Pass 匿名配额)+ RFC 9807(OPAQUE-3DH 增强口令认证密钥交换)+ RFC 9591(FROST 门限 Schnorr 签名 + Pedersen DKG + Feldman VSS) 四大 IETF 现代隐私与门限密码标准。全仓 0 份重复 SHA-2、0 份重复 Ristretto255、0 份重复 P-256、0 份重复 OPRF 实现,一套纯 MoonBit 代码零修改运行于 WebAssembly (Wasm) / JavaScript (JS / ESM) / Native (MSVC / Clang) 三端。
moon add CoolrfulDARkness/moonvoprfmoon run --target wasm cmd/mainmoon info && moon fmt --check && moon check -d
moon test --target wasm -d
moon test --target js -d
moon test --target native -d # Windows 下需先加载 VS MSVC vcvars64.batpython harness/interop_openssl.py
python harness/interop_rfc_suite.py默认运行不产生脏工作树:实时向量写入未跟踪且已加入 .gitignore 的 harness/openssl_vectors_live_test.mbt(全部通过后自动删除,失败保留作证据,--keep-vectors 可保留),因此连续运行后 git status --porcelain 为空;跟踪的 harness/openssl_vectors_generated_test.mbt 是冻结快照,仅在显式传入 --update-snapshot 时刷新。默认使用固定种子(--seed N / --random 可调),OpenSSL 侧密钥材料每次运行都是全新的。
moon build opaque/js_api --target js --release
node examples/web-demo/smoke.mjs
node examples/http-auth-demo/smoke_http.mjs
# 独立子模块原生 MoonBit Async HTTP/TCP 认证与 Privacy Pass 核销服务(2/2 Native E2E PASS):
cd examples/async_auth_server && moon test --target native -dcd examples/consumer
moon update && moon check -d
moon test --target wasm -d
moon test --target js -d自 0.3.1 起,发布包内随附的 examples/consumer/moon.mod 与包自身版本保持同一 pin(0.3.4 包内为 @0.3.4);此前 0.3.0 包内记录 0.2.0 属该版本的既成快照,已修正(详见 README.md 第 5 节与 docs/ROADMAP.md)。
// 1. RFC 9497 VOPRF 可验证盲求值
let suite = @voprf.CipherSuite::Ristretto255Sha512
let kp = @moonvoprf.derive_key_pair_for_mode(suite, @voprf.Mode::Voprf, seed32, b"issuer")
let st = @moonvoprf.voprf_blind(suite, b"secret-token", b"blind-seed")
let (evals, proof) = @moonvoprf.voprf_blind_evaluate(suite, kp.sk, kp.pk, [st.blinded_element], b"r")
let out = @moonvoprf.voprf_finalize(st, kp.pk, evals[0], proof)
// 2. RFC 9807 OPAQUE-3DH(底层直接委托给同一份 voprf Base OPRF)
let cfg = @opaque.Config::recommended_ristretto255_argon2id(context=b"app-v1")
let setup = @opaque.ServerSetup::from_seed(cfg.suite(), seed32).unwrap()
// 3. RFC 9591 FROST 2-of-3 门限签名(直接运行在共享 crypto/ristretto255 与 crypto/p256 之上)
let ops = @frost.ristretto255_sha512()
let drbg = @frost.drbg_from_seed(b"dkg-seed")
let (r1_sec, r1_pkg) = @frost.dkg_part1(ops, 1, 3, 2, drbg).unwrap()许可与第三方署名(License & Third-Party Notices):本仓库以 Apache-2.0 发布;Pages 编译产物内嵌 moonbitlang/core(Apache-2.0 · © IDEA),其 NOTICE 署名依 Apache-2.0 §4(d) 保留于根目录 NOTICE、Pages 随包 NOTICE.txt / LICENSE.txt 与产物头部横幅。详见 README.md 同名章节。
fn derive_key_pair_for_mode(suite : CipherSuite, mode : Mode, seed : Bytes, info : Bytes) -> KeyPair raise VoprfErrorfn oprf_blind_evaluate(suite : CipherSuite, sk : Bytes, blinded_element : Bytes) -> Bytes raise VoprfErrorfn oprf_blind_with_scalar(suite : CipherSuite, input : Bytes, blind_scalar : Bytes) -> BlindState raise VoprfErrorfn poprf_blind_evaluate(suite : CipherSuite, sk : Bytes, pk : Bytes, blinded_elements : Array[Bytes], info : Bytes, seed : Bytes) -> (Array[Bytes], Proof) raise VoprfErrorfn poprf_blind_evaluate_with_r(suite : CipherSuite, sk : Bytes, pk : Bytes, blinded_elements : Array[Bytes], info : Bytes, proof_r : Bytes) -> (Array[Bytes], Proof) raise VoprfErrorfn poprf_blind_with_scalar(suite : CipherSuite, input : Bytes, blind_scalar : Bytes) -> BlindState raise VoprfErrorfn poprf_finalize(state : BlindState, pk : Bytes, evaluated_element : Bytes, info : Bytes, proof : Proof) -> Bytes raise VoprfErrorfn poprf_finalize_batch(states : Array[BlindState], pk : Bytes, evaluated_elements : Array[Bytes], info : Bytes, proof : Proof) -> Array[Bytes] raise VoprfErrorfn poprf_full_evaluate(suite : CipherSuite, sk : Bytes, input : Bytes, info : Bytes) -> Bytes raise VoprfErrorfn voprf_blind_evaluate(suite : CipherSuite, sk : Bytes, pk : Bytes, blinded_elements : Array[Bytes], seed : Bytes) -> (Array[Bytes], Proof) raise VoprfErrorfn voprf_blind_evaluate_with_r(suite : CipherSuite, sk : Bytes, pk : Bytes, blinded_elements : Array[Bytes], proof_r : Bytes) -> (Array[Bytes], Proof) raise VoprfErrorfn voprf_blind_with_scalar(suite : CipherSuite, input : Bytes, blind_scalar : Bytes) -> BlindState raise VoprfErrorfn voprf_finalize(state : BlindState, pk : Bytes, evaluated_element : Bytes, proof : Proof) -> Bytes raise VoprfErrorfn voprf_finalize_batch(states : Array[BlindState], pk : Bytes, evaluated_elements : Array[Bytes], proof : Proof) -> Array[Bytes] raise VoprfErrorInstall
Download zipPure MoonBit, zero-FFI IETF modern privacy-authentication & threshold cryptography stack: RFC 9497 (OPRF/VOPRF/POPRF), RFC 9578 (Privacy Pass), RFC 9807 (OPAQUE-3DH), RFC 9591 (FROST + Pedersen DKG), RFC 9380 (Hash-to-Curve), RFC 9496 (Ristretto255), and RFC 7748 (X25519) over a single zero-duplication cryptographic core.