The Interfold 백서

The Interfold

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 45쪽 중 32쪽

ested and not finalized. CommitteeNotRequested , CommitteeAlreadyFinalized A usable seed exists. SortitionSeedUnavailable block.timestamp is at or before the ticket deadline. CommitteeDeadlineReached The operator has not submitted for this E3. NodeAlreadySubmitted The operator is enabled in the registry, currently active, and eligible at τ \tau τ . NodeNotEligible The ticket number is at least 1 and the frozen price is not zero. InvalidTicketNumber K i ≥ 1 K_i \ge 1 K i ​ ≥ 1 and the ticket number is at most K i K_i K i ​ . NodeNotEligible , InvalidTicketNumber The caller submits only a ticket number. The contract computes the score and emits TicketSubmitted(e3Id, node, ticketId, score) . An operator can submit once, even if its ticket does not enter the candidate set. Committee finalization Any caller can call finalizeCommittee(e3Id) after the deadline. The call requires block.timestamp to be greater than the deadline, or it reverts with SubmissionWindowNotClosed . Before the seed is ready, the deadline is the response deadline. Condition at finalization Result No usable seed The E3 fails with CommitteeFormationTimeout . Fewer than N candidates The E3 fails with InsufficientCommitteeMembers . N candidates The committee is finalized. A failure emits CommitteeFormationFailed(e3Id, nodesSubmitted, thresholdRequired) , calls onE3Failed , and releases the committee. On success, the registry does these steps: It sorts topNodes by ascending address ( RegistrySortitionLib.sortTopNodes ). It sets each member to Active and sets activeCount to N. It calls Interfold.onCommitteeFinalized . The E3 moves to CommitteeFinalized , and the DKG deadline becomes the ticket deadline plus dkgWindow . The call reverts with DKGDeadlinePassed if that deadline is already over. It emits SortitionCommitteeFinalized(e3Id, committee, scores) and CommitteeActivationChanged(e3Id, true) . Finalization also freezes the reward recipient of each member for this E3. Because a late finalization shortens the DKG time, the paid lifecycle does not become longer. If no caller finalizes a full committee before the DKG deadline, markE3Failed records CommitteeFormationTimeout . Finalization timers The Rust CommitteeFinalizer schedules one finalization attempt for each local ticket: t wait = max ⁡ ( t close − t now , 0 ) + 1 s + 30 s × party_index t_{\text{wait}} = \max(t_{\text{close}} - t_{\text{now}}, 0) + 1\,\text{s} + 30\,\text{s} \times \texttt{party\_index} t wait ​ = max ( t close ​ − t now ​ , 0 ) + 1 s + 30 s × party_index Before it sends, the writer runs a preflight call. If another member already finalized, the writer skips the transaction. If a sent transaction fails, the writer reads the state again. A terminal state is not an error. Other failures retry after 30 seconds. Party IDs After finalization, the party ID of a member is its index in the address-sorted committee. The lowest address is party 0. The runtime repeats the sort in CommitteeFinalized::sort_by_address , which compares lowercase address strings. Every node therefore derives the same party IDs, also for replayed events. The committee hash, the DKG proof inputs, and aggregator failover use this order. Aggregator assignment The active aggregator is the committee member with the lowest eligible party ID. A member becomes ineligible after an on-chain expulsion, a confirmed local exclusion, or a phase-local progress timeout. CiphernodeSelector publishes AggregatorChanged with the active party ID. Phase ( AggregationPhase ) Work of the active aggregator DkgRoster Collect signed readiness reports and propose one H-dealer roster. PublicKey Aggregate the roster key shares, prove C5, and call publishCommittee . Plaintext Aggregate T + 1 decryption shares, prove C7, and call publishPlaintextOutput . Each phase has a 10-minute budget ( AGGREGATOR_PROGRESS_TIMEOUT ). The budget starts only when the phase inputs are durable, which AggregationInputsReady reports. If the active party does not make progress in time, every node promotes the next eligible party in address order. The deadline and the phase-local skip set survive a restart. Protocol progress clears the skip set. When the last eligible party times out, it stays active so that late recovery is still possible. publishCommittee and publishPlaintextOutput are permissionless on-chain. The runtime sends them only from the active aggregator. The contract checks the proofs and accepts one result. End-to-end sequence Security properties Property Mechanism Unpredictable seed A verified VRF word is bound to the chain, the registry, the E3, and the request ID. No second draw A missing or late response fails the E3. No party can request replacement data. Deterministic scores The same packed Keccak hash runs in Solidity and in Rust. Snapshot stability Balances, eligibility, owners, and the price come from τ \tau τ and the request. Owner concentration cap One seat for each snapshot owner. Different owner addresses remain a bypass. Canonical order Finalization and the runtime both sort by address before party IDs exist. Collateral during selection A current candidate holds a collateral obligation until it is displaced or released. The provider can delay or withhold a response. In that case, the E3 fails after the response deadline. A stale local projection can give a node a wrong shortlist. The chain still protects the cap, but it does not protect committee availability. Next steps PVDKG and ZK proofs What the finalized committee does next: key generation, proofs, and on-chain anchoring. Internals Tickets and sortition How an operator gets tickets and takes part in committees. Operators E3 lifecycle The stages, deadlines, and failure reasons of one E3. Concepts Contracts reference Deployed registry and provider addresses for each network. Reference Run a Voting Round PVDKG and ZK Proofs ## /internals/dkg Protocol Internals PVDKG and ZK Proofs PVDKG and ZK Proof Pipeline This page describes the publicly verifiable distributed key generation (PVDKG) and the zero-knowledge proof pipeline of the Interfold. It is for auditors and core contributors. It covers the circuits, the DKG state machine, the phases P1 to P4, proof aggregation, on-chain anchoring, and the behavior when committee members crash. At the end, you can follow every proof from the ciphernode that makes it to the contract that checks it. Key generation. Up to 19 members publish proven contributions. The key uses an accepted roster of 14. The scheme is threshold BFV. After sortition finalizes a committee of N ciphernodes, the committee selects an accepted roster of H dealers. The threshold public key is the sum of the H roster contributions. Each roster member holds a Shamir share of the matching secret key, and any T + 1 roster members can decrypt together. The circuits are written in Noir and proved with Barretenberg ( bb ) as UltraHonk proofs. For the cryptographic specification, read the PVDKG article (opens in a new tab) . Terminology Term Definition Individual key pair A BFV key pair that one ciphernode makes for one DKG. It encrypts the Shamir shares sent to that node. Secret key contribution One ciphernode's part of the threshold secret key. Public key share The threshold BFV public key that matches one secret key contribution. Smudging noise contribution One ciphernode's part of the smudging noise that protects partial decryptions. Secret key share The Shamir share of the summed secret key that one roster member holds after C4. Smudging noise share The Shamir share of the summed smudging noise that one roster member holds after C4. Threshold public key The sum of the roster public key shares. Data providers encrypt to this key. Partial decryption One roster member's decryption share of a ciphertext, before reconstruction. Committee size N The number of ciphernodes that finalizeCommittee selects. Threshold T The polynomial degree of the Shamir sharing. Decryption needs T + 1 valid shares. Roster size H The exact number of dealers whose contributions form the threshold key. Accepted roster S The ascending list of H party IDs that the active aggregator proposes and every node accepts. Party ID The index of a member in the address-sorted committee. The lowest address is party 0. Active aggregator The member with the lowest eligible party ID. It coordinates the roster and the aggregate proofs. Committee shapes and fault budget crates/committee/src/lib.rs defines three committee shapes. The on-chain registry stores threshold as [H, N] . The runtime field threshold_m carries T and threshold_n carries N. Committee N T H Members that can drop before the roster ( N − H N - H N − H ) Roster members that can drop before decryption ( H − ( T + 1 ) H - (T + 1) H − ( T + 1 ) ) minimum 3 1 2 1 0 micro 9 4 5 4 0 small 19 9 14 5 4 These numbers describe the circuit shape and the liveness budget. An omitted member is not proven dishonest. Circuit map The ProofType enum in crates/events/src/interfold_event/signed_proof.rs names each node-made proof. Its numeric value is the proofType that slashing evidence uses. The CircuitName enum in crates/events/src/interfold_event/proof.rs maps each proof to a package under circuits/bin/ . ID ProofType (value) CircuitName Package Phase Proves C0 C0PkBfv (0) PkBfv dkg/pk P1 Commits to the individual public key used for share encryption. C1 C1PkGeneration (1) PkGeneration threshold/pk_generation P1 The public key share comes from the committed secret key contribution. C2a C2aSkShareComputation (2) SkShareComputation dkg/sk_share_computation P1 The secret key Shamir shares match the C1 commitment and are a valid sharing. C2b C2bESmShareComputation (3) ESmShareComputation dkg/e_sm_share_computation P1 The same for the smudging noise shares. C3a C3aSkShareEncryption (4) ShareEncryption dkg/share_encryption P1 A secret key share is BFV-encrypted under the recipient's C0 key. C3b C3bESmShareEncryption (5) ShareEncryption dkg/share_encryption P1 The same for a smudging noise share. C4a C4aSkShareDecryption (6) DkgShareDecryption dkg/share_decryption P1 The decrypted roster shares match their C2a commitments. Commits to their sum. C4b C4bESmShareDecryption (7) DkgShareDecryption dkg/share_decryption P1 The same for the smudging noise shares. C5 C5PkAggregation (8) PkAggregation threshold/pk_aggregation P2 The threshold public key is the sum of the H roster shares committed in C1. C6 C6ThresholdShareDecryption (9) ThresholdShareDecryption threshold/share_decryption P4 A partial decryption uses the C4 secret key and smudging noise shares. C7 C7DecryptedSharesAggregation (10) DecryptedSharesAggregation threshold/decrypted_shares_aggregation P4 Lagrange interpolation, CRT reconstruction, and decoding give the plaintext. P3 uses the user-data encryption packages threshold/user_data_encryption_ct0 , threshold/user_data_encryption_ct1 , and the wrapper threshold/user_data_encryption . They have no ProofType because data providers, not ciphernodes, make these proofs. Recursive aggregation circuits The packages under circuits/bin/recursive_aggregation/ fold the inner proofs into two on-chain proofs. Package CircuitName Role c2ab_fold C2abFold Folds C2a and C2b. c3_fold , c3_fold_kernel C3Fold , C3FoldKernel Folds the C3 proofs of one branch in sequence. The kernel makes the first accumulator. c3ab_fold C3abFold Folds the final secret key and smudging noise C3 folds. c4ab_fold C4abFold Folds C4a and C4b. node_fold NodeFold Folds C0, C1, c2ab_fold , c3ab_fold , and c4ab_fold for one node. nodes_fold , nodes_fold_kernel NodesFold , NodesFoldKernel Folds the H node_fold proofs in sequence. dkg_aggregator DkgAggregator Verifies nodes_fold and C5. Its EVM proof goes to publishCommittee . c6_fold , c6_fold_kernel C6Fold , C6FoldKernel Folds the T + 1 C6 proofs of one ciphertext. decryption_aggregator DecryptionAggregator Verifies c6_fold and C7. Its EVM proof goes to publishPlaintextOutput . Proof count per E3 L is the number of threshold CRT moduli: 2 for insecure-512 and 3 for secure-8192 . The current TrBFV code makes one smudging noise share set, so the smudging multiplicity Z is 1. Circuit Count for one node Count for the committee C0 1 Up to N C1 1 Up to N C2a 1 Up to N C2b 1 Up to N C3a ( N − 1 ) ⋅ L (N - 1) \cdot L ( N − 1 ) ⋅ L Up to N ( N − 1 ) L N (N - 1) L N ( N − 1 ) L C3b ( N − 1 ) ⋅ L ⋅ Z (N - 1) \cdot L \cdot Z ( N − 1 ) ⋅ L ⋅ Z Up to N ( N − 1 ) L Z N (N - 1) L Z N ( N − 1 ) L Z C4a 1 H used in the key C4b Z Z Z H used in the key C5 1 (active aggregator) 1 C6 1 for each ciphertext output T + 1 used for each ciphertext output C7 1 for each ciphertext output (active aggregator) 1 for each ciphertext output C3 is the most expensive circuit. Its witness is N wide, also when some C0 keys are missing. A dealer proves every slot except its own. For a recipient without a C0 key, the dealer encrypts the share under its own C0 key to fill the slot. The dealer does not deliver that placeholder. Two key hierarchies The protocol uses two different BFV key pairs. They use different parameter sets. Key Preset ( BfvPreset ) Purpose Lifetime Individual key InsecureDkg512 or SecureDkg8192 Encrypts the Shamir shares sent to one node. C0 commits to it. One DKG Threshold key InsecureThreshold512 or SecureThreshold8192 Data providers encrypt to it. C1 proves each contribution. One E3 The threshold key uses a common random polynomial (CRP) a a a . Every node derives the same CRP from the default seed with create_deterministic_crp_from_default_seed . The node encrypts its individual secret key at rest with its local Cipher (AES-256-GCM with an Argon2id key). DKG state machine Each selected ciphernode runs one ThresholdKeyshare actor for the E3. The actor moves through the KeyshareState enum in crates/keyshare/src/threshold_keyshare/state.rs . State Work in this state CollectingEncryptionKeys Make the individual key pair, request C0, and collect peer C0 keys. GeneratingThresholdShare Make the TrBFV contribution and the Shamir shares, then request C1, C2, and C3. AggregatingDecryptionKey Collect and verify peer shares, publish signed readiness, accept one roster, and compute local key shares. ReadyForDecryption Prove C4, exchange DecryptionKeyShared , verify peer C4 proofs, and publish KeyshareCreated . Decrypting Compute the partial decryption of each ciphertext output. GeneratingDecryptionProof Wait for the signed C6 proofs. Completed The node published its decryption share. Every state except Completed can move to Failed { failed_at_stage, reason } . A persisted failure can only be written again with the same payload, so a restart cannot resume an earlier phase. P1: Distributed key generation Frozen DKG timing When CiphernodeSelected arrives, the node reads getDeadlines(e3Id) and getE3TimeoutConfig(e3Id) from the Interfold contract. It persists the frozen DKG deadline and window before it makes keys. The DKG deadline is the ticket deadline plus dkgWindow . Each collector cutoff is a fraction of that window, measured from the ticket deadline: t cut = min ⁡  ⁣ ( t dkg − W dkg + ⌊ W dkg ⋅ bps 10 000 ⌋ , t dkg ) t_{\text{cut}} = \min\!\left(t_{\text{dkg}} - W_{\text{dkg}} + \left\lfloor \frac{W_{\text{dkg}} \cdot \text{bps}}{10\,000} \right\rfloor,\ t_{\text{dkg}}\right) t cut ​ = min ( t dkg ​ − W dkg ​ + ⌊ 10 000 W dkg ​ ⋅ bps ​ ⌋ , t dkg ​ ) Collector Cutoff (bps) Kind Override variable EncryptionKeyCollector 1000 (10%) Hard cutoff for C0 keys E3_ENCRYPTION_KEY_COLLECTION_TIMEOUT_SECS ThresholdShareCollector 7500 (75%) Soft checkpoint. The hard stop is the DKG deadline. E3_THRESHOLD_SHARE_COLLECTION_TIMEOUT_SECS DecryptionKeySharedCollector 10000 (100%) Hard cutoff at the DKG deadline E3_DECRYPTION_KEY_SHARED_COLLECTION_TIMEOUT_SECS An override variable can only make a cutoff earlier. After a restart, a collector uses the time that remains, not a new window. The mainnet configuration sets dkgWindow to 21600 seconds. The C0 cutoff is then 36 minutes after the ticket deadline, and the soft checkpoint is at 4.5 hours. C0: individual key commitment The node makes its individual BFV key pair and publishes EncryptionKeyPending . ProofRequestActor requests ZkRequest::PkBfv . C0 takes the individual public key polynomials p k 0 pk_0 p k 0 ​ and p k 1 pk_1 p k 1 ​ over the DKG moduli and outputs pk_commitment . C0 does not prove correct key generation. It binds the key so that C3 can prove which key encrypted each share. The node publishes EncryptionKeyCreated with the signed C0 proof. Receivers verify it in ProofVerificationActor before they store the key. Before reserving a verification slot, the receiver checks the committee signer, E3, C0 proof type, and commitment to the advertised key. The EncryptionKeyCollector finishes when all N keys arrive. At the C0 cutoff, it continues if it has at least H keys that include the node's own key. With fewer keys, the node records DKGTimeout and stops. A local verifier error leaves C0 verification pending. The receiver retains the authenticated input and retries after five seconds. Each failed attempt doubles the delay, up to 60 seconds, and logs a warning with the attempt count. Verification completion, a canonical stage past DKG, or E3RequestComplete clears the request. Startup restores unresolved inputs from durable events, including inputs before the snapshot cursor, and resumes verification after EffectsEnabled . The retry delay and attempt count reset on restart. Recovery continues past legacy records that the event-store router quarantines, including whole pages limited by record count or bytes. It checks the physical log head before it ends the scan. Other sequence gaps remain startup errors. A missing verifier binary, missing verification key, or local I/O error produces no peer-failure evidence. Only a completed invalid check starts the accusation path. C1: threshold share generation The node requests GenPkShareAndSkSss and then GenEsiSss from TrBFV. It gets its secret key contribution s k sk s k , its public key share, its smudging noise contribution e s m e_{sm} e s m ​ , and N Shamir shares of each secret. C1 proves the BFV key generation relation for each CRT modulus q ℓ q_\ell q ℓ ​ : p k 0 = − a ⋅ s k + e + r 2 ⋅ ( X d + 1 ) + r 1 ⋅ q ℓ , p k 1 = a pk_0 = -a \cdot sk + e + r_2 \cdot (X^{d} + 1) + r_1 \cdot q_\ell, \qquad pk_1 = a p k 0 ​ = − a ⋅ s k + e + r 2 ​ ⋅ ( X d + 1 ) + r 1 ​ ⋅ q ℓ ​ , p k 1 ​ = a Here d d d is the ring degree, and r 1 r_1 r 1 ​ and r 2 r_2 r 2 ​ are quotient witnesses. The circuit checks the relation at one Fiat-Shamir challenge point (the Schwartz-Zippel method). C1 outputs three commitments in this order: sk_commitment for C2a, pk_commitment for C5, and e_sm_commitment for C2b. C2: share computation C2a proves the secret key sharing and C2b proves the smudging noise sharing. For each coefficient i i i and modulus j j j , the share vector is y i , j = ( f ( 0 ) , f ( 1 ) , … , f ( N ) ) y_{i,j} = (f(0), f(1), \dots, f(N)) y i , j ​ = ( f ( 0 ) , f ( 1 ) , … , f ( N )) with f ( 0 ) f(0) f ( 0 ) equal to the secret coefficient. Each circuit checks four properties: The secret hashes to expected_secret_commitment from C1. The first entry of each share vector equals the secret coefficient. Every share is in [ 0 , q j ) [0, q_j) [ 0 , q j ​ ) . The shares lie on a polynomial of degree at most T. The Reed-Solomon parity check is H j ⋅ y i , j ⊤ ≡ 0 ( m o d q j ) H_j \cdot y_{i,j}^{\top} \equiv 0 \pmod{q_j} H j ​ ⋅ y i , j ⊤ ​ ≡ 0 ( mod q j ​ ) , with a parity matrix of size ( N − T ) × ( N + 1 ) (N - T) \times (N + 1) ( N − T ) × ( N + 1 ) . C2 outputs one commitment for each (party, modulus) pair, an N × L N \times L N × L grid. C3 and C4 consume this gri
프로젝트로 돌아가기