본문으로 건너뛰기

증거 확인

본인 증명 확인하기

교정은 표준 SP1 압축 교정입니다. SP1 SDK로 확인하세요.

use sp1_sdk::{ProverClient, SP1ProofWithPublicValues};

let client = ProverClient::from_env();
let (_, vk) = client.setup(ELF);
let proof = SP1ProofWithPublicValues::load("proof.bin")?;
client.verify(&proof, &vk)?;

확인 키는 게스트 프로그램 바이너리에서 파생된 결정적입니다. 누구나 재현할 수 있습니다.
ZkEVM SP1 게스트 프로그램의 불변성은 프로그램 키로 입증됩니다. 증명자 소스 코드는 GitHub에서 확인할 수 있습니다. 누구나 이를 컴파일하고 프로그램 키를 비교할 수 있습니다. SP1 게스트 프로그램에서 변경 사항이 수행되면 프로그램 키가 변경됩니다.

이름 증명 확인하기

이름을 확인하면 API는 128개의 형제 해시로 구성된 merkle_proof 필드 내에 멤버십 증명을 반환합니다. 이러한 형제 해시를 사용하여 도메인 이름과 대상 shielded 주소 간의 매핑을 로컬에서 확인할 수 있습니다.

다음은 확인된 이름의 SMT(Sparse Merkle Tree) 증명을 확인하는 방법을 보여주는 Python, PHP 및 JavaScript의 예입니다.

import hashlib

def get_bit(key_bytes, bit_idx):
"""
Returns the bit value (0 or 1) at a given index (0 to 127)
from MSB to LSB of the 16-byte key.
"""
byte_pos = bit_idx // 8
bit_pos = 7 - (bit_idx % 8)
return (key_bytes[byte_pos] >> bit_pos) & 1

def verify_smt_proof(domain_name, target_address, merkle_proof, expected_root):
# 1. Compute key as SHA-256 of lowercase domain name
key_hash = hashlib.sha256(domain_name.lower().encode('utf-8')).digest()
# Take first 16 bytes (128 bits) for a depth-128 SMT
key = key_hash[:16]

# 2. Compute leaf hash as SHA-256 of target address
current = hashlib.sha256(target_address.encode('utf-8')).digest()

# 3. Hash up the tree using the 128 sibling hashes
# Sibling proof array goes from bottom (closest to leaf, index 0) to top (closest to root, index 127)
for i in range(128):
sibling = bytes.fromhex(merkle_proof[i])

# Level 127 (index 0) corresponds to the bottom-most bit (bit 127)
# Level 0 (index 127) corresponds to the top-most bit (bit 0)
bit_idx = 127 - i
bit = get_bit(key, bit_idx)

if bit == 1:
# Current node is on the right, sibling is on the left
current = hashlib.sha256(sibling + current).digest()
else:
# Current node is on the left, sibling is on the right
current = hashlib.sha256(current + sibling).digest()

return current.hex() == expected_root.lower()