use notareum::CreateNotaOptions;
use tiny_keccak::{Hasher, Keccak};
// 1. Create and sign a .nota file
let signed = ntm.nota
.create(CreateNotaOptions {
type_: "address".into(),
chain_name: "ethereum".into(),
chain_id: 1,
identifier: "0xabc...".into(),
alias: Some("alice.eth".into()),
..CreateNotaOptions::new("address", "ethereum", 1, "0xabc...")
})?
.validate()?
.sign(&private_key_hex)?;
let wire = signed.serialize()?;
// 2. Compute proof hash (keccak256 of canonical bytes)
let mut hasher = Keccak::v256();
let mut out = [0u8; 32];
hasher.update(wire.as_bytes());
hasher.finalize(&mut out);
let proof_hash = format!("0x{}", hex::encode(out));
// 3. Register
let tx_hash = ntm.registry
.register_resource(0u8, 1u64, "0xabc...", &proof_hash, Some("alice.eth"))
.await?;
println!("Registered: {tx_hash}");
// 4. Later, anyone resolves it
let resource_id = ntm.registry.resolve_alias("alice.eth").await?;
let info = ntm.registry.get_resource(&resource_id).await?;
println!("{} level={}", info.owner, info.verification_level);