The Interfold 백서

The Interfold

원문

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

the call that enters it, its events, and its deadline. Learn Cryptography Threshold BFV, the DKG, and the circuits behind each proof. Learn Contracts Deployed addresses and contract interfaces. Reference What is an E3? E3 Lifecycle ## /learn/e3-lifecycle Learn E3 Lifecycle E3 Lifecycle The Interfold contract ( Interfold.sol ) moves each E3 through a fixed set of stages. This page gives the call that enters each stage, who makes the call, the events, and what happens next. It also covers the deadlines, the failure reasons, and refunds. It is for developers who request or watch E3s and for operators who serve on committees. The stages are the values of E3Stage in interfaces/IInterfold.sol : None , Requested , CommitteeFinalized , KeyPublished , CiphertextReady , Complete , and Failed . None means that the E3 does not exist. Every stage change emits E3StageChanged(e3Id, previousStage, newStage) . E3 lifecycle 1 Requested 2 Committee​Finalized 3 Key​Published 4 Ciphertext​Ready 5 Complete 6 Failed 01 Requester E3Requested Requested The requester calls Interfold.request(params) and pays the fee. The contract stores the E3 and asks the CiphernodeRegistry for a committee. Next, ciphernodes submit tickets after the VRF result arrives. Stage reference Stage Call that enters it Usual caller Interfold events Requested Interfold.request Requester E3Requested , E3StageChanged CommitteeFinalized CiphernodeRegistry.finalizeCommittee , then onCommitteeFinalized A committee candidate CommitteeFinalized , E3StageChanged KeyPublished CiphernodeRegistry.publishCommittee , then onCommitteePublished Active aggregator CommitteeFormed , E3StageChanged CiphertextReady Interfold.publishCiphertextOutput Application server CiphertextOutputReferencePublished , E3StageChanged Complete Interfold.publishPlaintextOutput Active aggregator PlaintextOutputPublished , E3StageChanged Failed markE3Failed , cancelE3 , or a call from the registry or slashing manager Anyone, after a deadline E3Failed , E3StageChanged finalizeCommittee , publishCommittee , publishCiphertextOutput , and publishPlaintextOutput have no caller restriction. Stage checks, deadline checks, and proof verification protect them. The "Usual caller" column shows who sends the transaction in the current software. Requested The requester calls request(E3RequestParams) . The parameters are committeeSize , inputWindow , e3Program , paramSet , computeProviderParams , customParams , expectedFeeToken , expectedCryptoConfigId , and maxFee . The contract rejects the request in these conditions: Requests are paused, or the E3 program is not registered. The fee token is not allowed, or it is different from expectedFeeToken . The circuit configuration for paramSet is different from expectedCryptoConfigId . The quote from getE3Quote is more than maxFee . inputWindow[0] is before the current time, or inputWindow[1] is before inputWindow[0] . The worst-case lifecycle duration is more than maxDuration . When the checks pass, the contract takes the fee. It keeps the service fee in escrow and credits the flat randomness fee to the treasury. It calls the program validate function, which returns the encryption scheme. It also records the timeout configuration and the dependent contracts for this E3. The contract then calls CiphernodeRegistry.requestCommittee . The registry checks that at least N operators were active just before the request. It records the ticket price and the IMT root, and it requests one random word from the randomness provider. The registry emits CommitteeRandomnessRequested and DkgFoldAttestationContextEstablished . After the Chainlink VRF v2.5 result arrives, ciphernodes call submitTicket(e3Id, ticketNumber) . Each accepted ticket emits TicketSubmitted . The ticket window is sortitionSubmissionWindow seconds from the VRF fulfillment time. See Sortition . CommitteeFinalized After the committee deadline, anyone can call finalizeCommittee(e3Id) . In the current software, committee candidates schedule this call 30 seconds apart by party index, so one member acts first. The registry then checks the result of sortition: If no usable VRF result exists, the E3 fails with CommitteeFormationTimeout . If fewer than N tickets were submitted, the E3 fails with InsufficientCommitteeMembers . Otherwise, the registry sorts the committee by address and calls onCommitteeFinalized . In both failure cases, the registry also emits CommitteeFormationFailed . onCommitteeFinalized sets the DKG deadline and records the reward recipient for each member. The Interfold contract emits CommitteeFinalized . The registry emits SortitionCommitteeFinalized(e3Id, committee, scores) and CommitteeActivationChanged(e3Id, true) . Next, the committee runs DKG off-chain. The members exchange encrypted key shares and proofs (C0 to C4). The active aggregator selects a roster of H ready members and proves the key aggregation (C5). See Cryptography . KeyPublished The active aggregator calls publishCommittee(e3Id, pkCommitment, proof, dkgAttestationBundle) . The registry verifies the DKG proof with BfvPkVerifier and the fold attestations with DkgFoldAttestationVerifier . It stores the DKG anchors that the decryption proof uses later. The registry then calls onCommitteePublished . The Interfold contract accepts the key only before the DKG deadline and before inputWindow[1] . It sets the compute deadline and emits CommitteeFormed . The registry emits CommitteeProofPublished . The committee members also publish the serialized public key in chunks with publishCommitteePublicKey . Each chunk emits CommitteePublicKeyChunkPublished . A client rebuilds the key and checks it against pkCommitment before it encrypts. Next, data providers encrypt their inputs and call publishInput on the E3 program. The E3 program decides which inputs to accept during the input window. CiphertextReady The compute provider runs the secure process after inputWindow[1] . An application server then calls publishCiphertextOutput(e3Id, encodedOutputReference) . The reference contains the contentHash of the ciphertext bytes, the ciphertextCommitment , the computeProof , and the availabilityProof . The contract accepts the output only in these conditions: The E3 is in KeyPublished , and the compute deadline has not passed. The input window has closed. The committee still has enough active members. The E3 program accepts the availability receipt for contentHash . The ciphertext verifier and the E3 program verify function accept the compute proof. The contract stores the hash and the commitment, and it sets the decryption deadline. It emits CiphertextOutputReferencePublished . Next, each committee member computes a decryption share with a C6 proof. Complete The active aggregator combines T + 1 decryption shares and proves the result (C7). It calls publishPlaintextOutput(e3Id, plaintextOutput, proof) . The contract accepts the output only before the decryption deadline, with a viable committee and a valid decryption proof. The contract stores the plaintext and pays for the work: It credits the protocol share ( protocolShareBps , recorded at request time) to the treasury. It splits the rest of the service fee among the active committee members. Each reward recipient claims with claimReward(e3Id) or claimRewards(e3Ids) . The contract emits PlaintextOutputPublished , RewardsDistributed , and RewardCredited for each member. Applications read the result from getE3(e3Id).plaintextOutput or from the PlaintextOutputPublished event. Failed An E3 enters Failed in one of these ways: Timeout. After a deadline, anyone calls markE3Failed(e3Id) . The contract selects the reason from the current stage. Committee formation. finalizeCommittee records CommitteeFormationTimeout or InsufficientCommitteeMembers . Committee viability. A slash expels a member, and the active members drop below H. The SlashingManager records InsufficientCommitteeMembers . Cancellation. The requester calls cancelE3(e3Id) . This is possible only in Requested , when no usable VRF result exists and the committee deadline has passed. The reason is CommitteeFormationTimeout . The contract emits E3Failed(e3Id, failedAtStage, reason) . If a later expulsion shows that the committee caused a requester-side failure, the SlashingManager changes the reason to InsufficientCommitteeMembers . The contract then emits E3FailureReclassified . This change is possible only before refund settlement. Deadlines and timeouts Each E3 records the timeout configuration at request time. A later governance change does not affect an existing E3. Deadline Set when Value Reason when it passes Committee deadline Request, then VRF result Request time + randomnessRequestTimeout . After a usable VRF result: fulfillment time + sortitionSubmissionWindow CommitteeFormationTimeout DKG deadline CommitteeFinalized Committee deadline + dkgWindow DKGTimeout Compute deadline KeyPublished The later of key publication time and inputWindow[1] , + computeWindow ComputeTimeout Decryption deadline CiphertextReady Ciphertext publication time + decryptionWindow DecryptionTimeout A late finalization does not move the DKG deadline. It leaves less time for DKG. In Requested , a committee with enough tickets can still finalize until the DKG deadline. For that case, markE3Failed accepts the failure only after the committee deadline + dkgWindow . The committee key must arrive before inputWindow[1] . The contract rejects a later key, and the E3 then fails with DKGTimeout . A safe inputWindow[1] is later than the request time plus the randomness timeout, the ticket window, and the DKG window. The contract also limits the total duration. At request time, it computes the later of inputWindow[1] and the committee setup time ( randomnessRequestTimeout + sortitionSubmissionWindow + dkgWindow ). It adds computeWindow and decryptionWindow . The result must not be more than maxDuration . markFailedGracePeriod protects against short chain or RPC delays. During this period after a deadline, only the requester, the contract owner, or an active committee member can call markE3Failed . After the period, anyone can call it. A value of 0 removes the restriction. Configured values The mainnet values come from packages/interfold-contracts/deploy/protocol/mainnet-protocol.config.json . The local values are the defaults for local development deployments ( scripts/deployInterfold.ts and CiphernodeRegistryOwnable.sol ). Read the live values from the contracts: getTimeoutConfig , markFailedGracePeriod , maxDuration , sortitionSubmissionWindow , and randomnessRequestTimeout . Parameter Contract Mainnet Local development randomnessRequestTimeout CiphernodeRegistry 3,600 s (1 hour) 3,600 s (1 hour) sortitionSubmissionWindow CiphernodeRegistry 600 s (10 minutes) 60 s dkgWindow Interfold 21,600 s (6 hours) 7,200 s (2 hours) computeWindow Interfold 604,800 s (7 days) 86,400 s (1 day) decryptionWindow Interfold 21,600 s (6 hours) 3,600 s (1 hour) markFailedGracePeriod Interfold 3,600 s (1 hour) 0 maxDuration Interfold 2,592,000 s (30 days) 2,592,000 s (30 days) Failure reasons FailureReason in interfaces/IInterfold.sol lists the reasons. FailurePayerLib.sol assigns the cost of each reason to the requester side or to the ciphernode side. Value Reason Recorded by Cost falls on 0 None Not a failure None 1 CommitteeFormationTimeout markE3Failed in Requested , finalizeCommittee , cancelE3 Ciphernodes 2 InsufficientCommitteeMembers finalizeCommittee , SlashingManager Ciphernodes 3 DKGTimeout markE3Failed in CommitteeFinalized Ciphernodes 4 DKGInvalidShares No contract path in this release Ciphernodes 5 NoInputsReceived No contract path in this release Requester 6 ComputeTimeout markE3Failed in KeyPublished Requester 7 ComputeProviderExpired No contract path in this release Requester 8 ComputeProviderFailed No contract path in this release Requester 9 RequesterCancelled Reserved for ABI compatibility. cancelE3 records reason 1. Requester 10 DecryptionTimeout markE3Failed in CiphertextReady Ciphernodes 11 DecryptionInvalidShares No contract path in this release Ciphernodes 12 VerificationFailed No contract path in this release Ciphernodes onE3Failed rejects None , RequesterCancelled , and any value from _MAX_FAILURE_REASON up. Requester-side reasons cover failures of the requester, the data providers, and the compute provider. Refunds Interfold keeps only the service fee in escrow. The flat randomness fee goes to the treasury at request time. No success, failure, or cancellation path returns the randomness fee. After an E3 fails, the funds move in this sequence: Anyone calls processE3Failure(e3Id) . The Interfold contract sends the service fee escrow to E3RefundManager and emits E3FailureProcessed . E3RefundManager calculates the split from the failure reason and the policy recorded at request time. The requester calls claimRequesterRefund(e3Id) . The reward recipient of each honest committee member calls claimHonestNodeReward(e3Id, operator) . The split depends on the side that caused the failure: Ciphernode side. The requester gets 100% of the service fee escrow. The treasury gets nothing, and the fee does not pay honest nodes. Honest nodes get compensation only from collateral slashed from faulty nodes. Requester side. Honest committee members get a share for the work that they completed. The treasury gets the protocol share. The requester gets the rest. If no honest node exists, the node share also goes to the requester. The Requesting an E3 page explains fees, quotes, and refund claims in detail. Next steps Requesting an E3 Get a quote, choose the input window, submit the request, and claim refunds. Build Cryptography What the DKG and decryption proofs show, circuit by circuit. Learn Exits and slashing How faults lead to slashes, bans, and committee expulsion. Operate Architecture Cryptography ## /learn/cryptography Learn Cryptography Cryptography This page explains the cryptography that protects an E3. It covers threshold BFV encryption, distributed key generation (DKG), and the zero-knowledge (ZK) proofs that make each step publicly verifiable. It is for developers and operators who want to know what the protocol proves and where. At the end, you can map each protocol step to its circuit and to its on-chain verifier. The PVDKG and ZK proof pipeline page gives the full detail. Building blocks Building block Implementation Job in an E3 BFV fully homomorphic encryption The gnosisguild/fhe.rs library, scheme ID keccak256("fhe.rs:BFV") Compute on encrypted integers Threshold BFV (TrBFV) crates/trbfv Split the secret key across the committee Shamir secret sharing Part of TrBFV Give each member a share of each key contribution ZK proofs Noir circuits in circuits/ , proved with Barretenberg UltraHonk ( bb ) Prove each key, share, and decryption step Commitments The SAFE sponge with the Poseidon2 permutation ( circuits/lib/src/math/safe.nr ) Link circuits without publishing large polynomials BFV BFV works in the polynomial ring R q = Z q [ X ] / ( X d + 1 ) R_q = \mathbb{Z}_q[X]/(X^d + 1) R q ​ = Z q ​ [ X ] / ( X d + 1 ) . The degree d d d is 512 or 8192. The ciphertext modulus q q q is a product of CRT moduli q ℓ q_\ell q ℓ ​ , and t t t is the plaintext modulus. A key pair has a secret key s s s and a public key ( p k 0 , p k 1 ) (\mathrm{pk}_0, \mathrm{pk}_1) ( pk 0 ​ , pk 1 ​ ) . A message m m m encrypts to a ciphertext ( c t 0 , c t 1 ) (\mathrm{ct}_0, \mathrm{ct}_1) ( ct 0 ​ , ct 1 ​ ) , with small random polynomials u u u , e e e , e 0 e_0 e 0 ​ , and e 1 e_1 e 1 ​ and the scale factor Δ = ⌊ q / t ⌋ \Delta = \lfloor q/t \rfloor Δ = ⌊ q / t ⌋ : p k 0 = − a s + e , p k 1 = a \mathrm{pk}_0 = -a\,s + e, \qquad \mathrm{pk}_1 = a pk 0 ​ = − a s + e , pk 1 ​ = a c t 0 = p k 0 u + e 0 + Δ m , c t 1 = p k 1 u + e 1 \mathrm{ct}_0 = \mathrm{pk}_0\,u + e_0 + \Delta m, \qquad \mathrm{ct}_1 = \mathrm{pk}_1\,u + e_1 ct 0 ​ = pk 0 ​ u + e 0 ​ + Δ m , ct 1 ​ = pk 1 ​ u + e 1 ​ Decryption computes c t 0 + c t 1 s m o d q \mathrm{ct}_0 + \mathrm{ct}_1 s \bmod q ct 0 ​ + ct 1 ​ s mod q , which is Δ m \Delta m Δ m plus small noise. It then scales by t / q t/q t / q and rounds to get m m o d t m \bmod t m mod t . The sum of two ciphertexts decrypts to the sum of the two messages. The default template and CRISP both use this addition. BFV also supports multiplication, but each multiplication uses part of a limited noise budget. Threshold BFV In threshold BFV, no party holds s s s . Three numbers define each committee: N is the committee size that sortition selects. H is the number of dealer contributions that form the key. The active aggregator selects an ascending roster S S S of H members that are all ready. T is the threshold. Decryption needs T + 1 shares from the roster. Size N H T T + 1 Members that can drop before the roster Roster members that can drop before decryption Minimum 3 2 1 2 1 0 Micro 9 5 4 5 4 0 Small 19 14 9 10 5 4 The values come from crates/committee/src/lib.rs and packages/interfold-contracts/contracts/lib/ActiveCryptoConfig.sol . Key generation. Members exchange encrypted shares. The key comes from a roster of 14 contributions. Key generation Each member h h h makes a secret contribution s h s_h s h ​ and a public key share. It splits s h s_h s h ​ into Shamir shares with a polynomial of degree T. It encrypts each share under the recipient's individual BFV key and sends it. The same process runs for smudging noise e s m e_{\mathrm{sm}} e sm ​ , which later hides each decryption share. The individual BFV keys protect only the share traffic during DKG. They are different from the threshold key that data providers use. After the share proofs pass, each member publishes a signed readiness report. The active aggregator then selects the roster S S S . The threshold secret and public key are: s = ∑ h ∈ S s h , p k 0 = ∑ h ∈ S p k 0 , h , p k 1 = a s = \sum_{h \in S} s_h, \qquad \mathrm{pk}_0 = \sum_{h \in S} \mathrm{pk}_{0,h}, \qquad \mathrm{pk}_1 = a s = h ∈ S ∑ ​ s h ​ , pk 0 ​ = h ∈ S ∑ ​ pk 0 , h ​ , pk 1 ​ = a All members use the same common polynomial a a a , so p k 1 \mathrm{pk}_1 pk 1 ​ is not a sum. Each roster member i i i adds the shares that it received from the roster into s k i \mathrm{sk}_i sk i ​ , its Shamir share of s s s . Threshold decryption Each roster member i i i computes a decryption share from the ciphertext output: d i = c t 0 + c t 1 s k i + e s m , i ( m o d q ) d_i = \mathrm{ct}_0 + \mathrm{ct}_1\,\mathrm{sk}_i + e_{\mathrm{sm},i} \pmod{q} d i ​ = ct 0 ​ + ct 1 ​ sk i ​ + e sm , i ​ ( mod q ) Ciphernodes use the committee key and decryption domain from confirmed chain state. Repeated matching key publications do not start more share calculations or proof requests. After a restart, the node resumes retained work when effects are enabled. Local worker failures retry the same request. The aggregator takes T + 1 shares with party coordinates x i x_i x i ​ . The coordinates start at 1, and they must be unique and in increasing order. The aggregator combines the shares with Lagrange coefficients at zero: L i ( 0 ) = ∏ j ≠ i x j x j − x i , u = ∑ i L i ( 0 ) d i ( m o d q ) L_i(0) = \prod_{j \neq i} \frac{x_j}{x_j - x_i}, \qquad u = \sum_i L_i(0)\,d_i \pmod{q} L i ​ ( 0 ) = j  = i ∏ ​ x j ​ − x i ​ x j ​ ​ , u = i ∑ ​ L i ​ ( 0 ) d i ​ ( mod q ) The coefficients L i ( 0 ) L_i(0) L i ​ ( 0 ) add up to 1, so u = c t 0 + c t 1 s u = \mathrm{ct}_0 + \mathrm{ct}_1 s u = ct 0 ​ + ct 1 ​ s plus small noise. The aggregator then decodes u u u to the plaintext, as in normal BFV decryption. T + 1 roster
프로젝트로 돌아가기