From e14168ee5369433e2711a04239cf1c9a66e803f6 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:10:04 +0000 Subject: [PATCH 1/8] feat(bfv)!: move the 45-party tuples to parameter-set indices 3 and 4 - Registration is append-only and live registries hold earlier tuples at indices 0, 1 and 2, so the 45-party tuples cannot take indices 0 and 2 in place. - ON_CHAIN_PARAMETER_SETS maps index 3 to secure-8192 and index 4 to insecure-64. BfvProtocol.sol and crypto-config.json are regenerated. - The indexer resolves indices 3 and 4 only through a current profile identity. It reads indices 0, 1 and 2 from the registry bytes under their frozen threshold-only ID: v5 at indices 0 and 2, v1 at indices 0 and 1. - bfv_protocol.json keeps the v0.19 tuples as historical v5 vectors, computed independently with ethers. - The SDK ParamSet enum, the fake Interfold fixture and the test inputs follow the new indices. BREAKING CHANGE: new requests use parameter set 3 (secure-8192) or 4 (insecure-64). Indices 0, 1 and 2 are historical. --- crates/bfv/params/src/presets.rs | 19 +-- crates/bfv/params/tests/fixtures/README.md | 7 +- .../params/tests/fixtures/bfv_protocol.json | 22 +++- crates/bfv/params/tests/profile_identity.rs | 8 +- crates/evm/indexer/src/indexer.rs | 124 +++++++++++++++--- .../indexer/tests/fixtures/fake_interfold.sol | 5 +- crates/evm/runtime/src/interfold/events.rs | 4 +- crates/state/request/src/routing/tests.rs | 2 +- .../contracts/Interfold.sol | 2 +- .../contracts/lib/BfvProtocol.sol | 4 +- .../interfold-contracts/crypto-config.json | 10 +- .../test/E3Lifecycle/E3Integration.spec.ts | 8 +- .../test/E3Lifecycle/Sortition.spec.ts | 2 +- .../test/Interfold.spec.ts | 45 ++++--- .../test/Pricing/DustRotation.spec.ts | 4 +- .../test/Pricing/Pricing.spec.ts | 4 +- .../Pricing/PullPaymentsAndAllowlist.spec.ts | 2 +- .../CiphernodeRegistryOwnable.spec.ts | 2 +- .../test/Slashing/CommitteeExpulsion.spec.ts | 2 +- .../test/fixtures/helpers.ts | 4 +- .../test/fixtures/system.ts | 4 +- packages/interfold-sdk/src/contracts/types.ts | 4 +- scripts/circuits/bfv-bindings.test.ts | 6 +- 23 files changed, 206 insertions(+), 88 deletions(-) diff --git a/crates/bfv/params/src/presets.rs b/crates/bfv/params/src/presets.rs index b4a902ca64..9cfa618342 100644 --- a/crates/bfv/params/src/presets.rs +++ b/crates/bfv/params/src/presets.rs @@ -68,14 +68,15 @@ pub enum BfvPreset { } impl BfvPreset { - /// Current registry entries. Historical indices do not identify current presets. + /// Current registry entries. Historical indices do not identify current presets: registration + /// is append-only, and indices 0, 1 and 2 hold earlier tuples on live chains. pub const ON_CHAIN_PARAMETER_SETS: [(u8, Self); 2] = [ - (0, Self::InsecureThreshold64), - (2, Self::SecureThreshold8192), + (4, Self::InsecureThreshold64), + (3, Self::SecureThreshold8192), ]; /// Map a supported on-chain parameter-set index to a threshold `BfvPreset`. - /// Return `None` for the historical secure index 1 and other unsupported indices. + /// Return `None` for the historical indices 0, 1 and 2 and other unsupported indices. pub fn from_on_chain_param_set(value: u8) -> Option { Self::ON_CHAIN_PARAMETER_SETS .iter() @@ -749,14 +750,16 @@ mod tests { } #[test] - fn old_secure_parameter_slot_has_no_preset() { + fn historical_parameter_slots_have_no_preset() { + for historical in [0, 1, 2] { + assert_eq!(BfvPreset::from_on_chain_param_set(historical), None); + } assert_eq!( - BfvPreset::from_on_chain_param_set(0), + BfvPreset::from_on_chain_param_set(4), Some(BfvPreset::InsecureThreshold64) ); - assert_eq!(BfvPreset::from_on_chain_param_set(1), None); assert_eq!( - BfvPreset::from_on_chain_param_set(2), + BfvPreset::from_on_chain_param_set(3), Some(BfvPreset::SecureThreshold8192) ); for (index, preset) in BfvPreset::ON_CHAIN_PARAMETER_SETS { diff --git a/crates/bfv/params/tests/fixtures/README.md b/crates/bfv/params/tests/fixtures/README.md index be1b1df718..5e53d27989 100644 --- a/crates/bfv/params/tests/fixtures/README.md +++ b/crates/bfv/params/tests/fixtures/README.md @@ -1,9 +1,10 @@ # BFV protocol compatibility vectors `bfv_protocol.json` contains exact ABI bytes and parameter hashes for current threshold presets, -plus historical threshold-only v5/v1 configuration IDs. The v5 records use registry indices 0 and 2; -v1 records retain their original indices 0 and 1. These IDs support historical indexing, not new -request or node admission. +plus historical threshold-only v5/v1 configuration IDs. Current records use registry indices 4 +(insecure) and 3 (secure). Historical records retain their original indices: the v5 records of the +v0.19 tuples use indices 0 and 2; the v1 records use indices 0 and 1. The threshold-only IDs support +historical indexing, not new request or node admission. The vectors were calculated independently with ethers v6 `AbiCoder`, `id`, and `keccak256`: diff --git a/crates/bfv/params/tests/fixtures/bfv_protocol.json b/crates/bfv/params/tests/fixtures/bfv_protocol.json index b26bf5edfd..7d17e33781 100644 --- a/crates/bfv/params/tests/fixtures/bfv_protocol.json +++ b/crates/bfv/params/tests/fixtures/bfv_protocol.json @@ -5,7 +5,7 @@ { "name": "current-insecure", "preset": "INSECURE_THRESHOLD_64", - "paramSet": 0, + "paramSet": 4, "circuitVersion": "interfold-bfv-v5", "encodedParameters": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000010366400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000007fffd810000000000000000000000000000000000000000000000000000000007fff8010000000000000000000000000000000000000000000000000000000007fff781000000000000000000000000000000000000000000000000000000000000000b3730373739303333363030000000000000000000000000000000000000000000", "parameterHash": "0x2898f8a9fbc317e2812695161febb2c738bf0548327f4805d0329c6f6bb3a844", @@ -14,12 +14,30 @@ { "name": "current-secure", "preset": "SECURE_THRESHOLD_8192", - "paramSet": 2, + "paramSet": 3, "circuitVersion": "interfold-bfv-v5", "encodedParameters": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000010366400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000800000000db40010000000000000000000000000000000000000000000000000800000000d540010000000000000000000000000000000000000000000000000800000000cbc001000000000000000000000000000000000000000000000000000000000000002938393732323838393731353438313832313432313137393931343739343631343238353932363430300000000000000000000000000000000000000000000000", "parameterHash": "0x4f4025982214c2149028270dccc0ad45c24c2441a3496cdf1a29f5d1e1b908c3", "cryptoConfigId": "0xceded5557de51373b24a54e2cc2ea5b08818f0f5abdc3f87851136941d33260b" }, + { + "name": "historical-insecure-v5", + "preset": null, + "paramSet": 0, + "circuitVersion": "interfold-bfv-v5", + "encodedParameters": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000010366400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000007fffd810000000000000000000000000000000000000000000000000000000007fff8010000000000000000000000000000000000000000000000000000000007fff781000000000000000000000000000000000000000000000000000000000000000b3132363137393239333836000000000000000000000000000000000000000000", + "parameterHash": "0xaff065a7d6e3d8c830dfcd37c2af8a25b3dcc6cd74ba458894075e8264f1ab1e", + "cryptoConfigId": "0x92c8b373eb72cc3600a5a818cf8599db16e618ee3ece2dadd14f8608c1a43ac9" + }, + { + "name": "historical-secure-v5", + "preset": null, + "paramSet": 2, + "circuitVersion": "interfold-bfv-v5", + "encodedParameters": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000010366400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000800000000db40010000000000000000000000000000000000000000000000000800000000d540010000000000000000000000000000000000000000000000000800000000cbc001000000000000000000000000000000000000000000000000000000000000002931373732333033393934333739383837383330353436303935353537303731313731373437383430300000000000000000000000000000000000000000000000", + "parameterHash": "0x1b2620f6a5919d5ee19a51f34026369816f479efd0404b56585ad37d31c52317", + "cryptoConfigId": "0xa174862efd4487031d423ca96516807775ade0191c714e513aab93d0cc289baa" + }, { "name": "historical-insecure-v1", "preset": null, diff --git a/crates/bfv/params/tests/profile_identity.rs b/crates/bfv/params/tests/profile_identity.rs index c49a3c0726..b9e444276a 100644 --- a/crates/bfv/params/tests/profile_identity.rs +++ b/crates/bfv/params/tests/profile_identity.rs @@ -46,8 +46,12 @@ fn every_supported_identity_resolves_to_its_own_profile_only() { assert_eq!(supported, 8); let unknown = B256::repeat_byte(0x12); - let error = BfvProfile::from_crypto_config_id(0, CiphernodesCommitteeSize::Minimum, unknown) - .unwrap_err(); + let error = BfvProfile::from_crypto_config_id( + BfvProfile::SsInsecure64.param_set(), + CiphernodesCommitteeSize::Minimum, + unknown, + ) + .unwrap_err(); assert!( matches!(&error, BfvProfileError::UnsupportedConfiguration(id) if *id == unknown.to_string()), "{error}" diff --git a/crates/evm/indexer/src/indexer.rs b/crates/evm/indexer/src/indexer.rs index 3eb6d52d2d..09f953f479 100644 --- a/crates/evm/indexer/src/indexer.rs +++ b/crates/evm/indexer/src/indexer.rs @@ -403,6 +403,22 @@ impl InterfoldIndexer { } } +/// Statement versions of the threshold-only configuration IDs that requests of a historical +/// registry slot carry. Registration is append-only, so current presets use later slots and these +/// slots keep their original bytes: slots 0 and 2 hold the v0.19 tuples (slot 0 on testnets), and +/// slots 0 and 1 hold the earlier Mainnet tuples. +fn historical_statement_versions(param_set: u8) -> &'static [&'static str] { + match param_set { + 0 => &[LEGACY_BFV_CONFIG_VERSION, "interfold-bfv-v1"], + 1 => &["interfold-bfv-v1"], + 2 => &[LEGACY_BFV_CONFIG_VERSION], + _ => &[], + } +} + +/// Resolve the parameter bytes of a request. A current slot resolves through its profile identity +/// to the local preset. A historical slot resolves to its registry bytes, and only under the +/// threshold-only identity those exact bytes had when the request was made. fn request_bfv_params( param_set: u8, committee_size: u8, @@ -410,21 +426,17 @@ fn request_bfv_params( historical_params: Option<&[u8]>, ) -> Result> { if let Some(preset) = BfvPreset::from_on_chain_param_set(param_set) { - let params = encode_bfv_params(&BfvParamSet::from(preset).build_arc()); if let Ok(committee) = CiphernodesCommitteeSize::try_from(committee_size) { if let Ok(profile) = BfvProfile::from_crypto_config_id(param_set, committee, request_config_id) { profile.ensure_admission_enabled()?; - return Ok(params); + return Ok(encode_bfv_params(&BfvParamSet::from(preset).build_arc())); } } - // Historical completed requests keep their original threshold-only v5 identity. - if request_config_id == bfv_crypto_config_id(¶ms, LEGACY_BFV_CONFIG_VERSION) { - return Ok(params); - } } - if param_set != 0 && param_set != 1 { + let versions = historical_statement_versions(param_set); + if versions.is_empty() { return Err(eyre!( "unsupported BFV parameter set {param_set} or configuration ID" )); @@ -434,7 +446,10 @@ fn request_bfv_params( .ok_or_else(|| eyre!("historical BFV parameter set {param_set} is not registered"))?; decode_bfv_params(params) .map_err(|error| eyre!("invalid historical BFV parameters: {error}"))?; - if request_config_id != bfv_crypto_config_id(params, "interfold-bfv-v1") { + if !versions + .iter() + .any(|version| request_config_id == bfv_crypto_config_id(params, version)) + { return Err(eyre!( "local circuit configuration does not match request-time config for parameter set {param_set}" )); @@ -467,7 +482,7 @@ async fn store_committee_public_key( request_crypto_config_id, None, ) { - Err(_) if e3.paramSet == 0 || e3.paramSet == 1 => { + Err(_) if !historical_statement_versions(e3.paramSet).is_empty() => { let historical_params = contract.get_param_set_registry(e3.paramSet).await?; request_bfv_params( e3.paramSet, @@ -1239,22 +1254,92 @@ mod public_key_chunk_tests { assert!(request_bfv_params(0, 0, id, Some(&extended)).is_err()); assert!(request_bfv_params(0, 0, extended_id, Some(¶ms)).is_err()); + let slot = BfvProfile::SsInsecure64.param_set(); let current = encode_bfv_params(&BfvParamSet::from(BfvPreset::InsecureThreshold64).build_arc()); let current_id = BfvProfile::SsInsecure64 .crypto_config_id(CiphernodesCommitteeSize::Minimum) .unwrap(); - assert_eq!(request_bfv_params(0, 0, current_id, None).unwrap(), current); - assert!(request_bfv_params(1, 0, current_id, Some(¤t)).is_err()); + assert_eq!( + request_bfv_params(slot, 0, current_id, None).unwrap(), + current + ); + // A historical slot never resolves a current identity, even over the current bytes. + for historical in [0, 1, 2] { + assert!(request_bfv_params(historical, 0, current_id, Some(¤t)).is_err()); + } let disabled = BfvProfile::SyncDecInsecure64 .crypto_config_id(CiphernodesCommitteeSize::Minimum) .unwrap(); - assert!(request_bfv_params(0, 0, disabled, Some(¤t)) + assert!(request_bfv_params(slot, 0, disabled, Some(¤t)) .unwrap_err() .to_string() .contains("disabled")); } + #[test] + fn v019_slots_keep_their_registered_bytes_and_threshold_only_identity() { + // The v0.19 tuples that live registries hold: the insecure one at slot 0 (Sepolia) and + // the secure one at slot 2 (Mainnet and Sepolia). + let insecure = ( + U256::from(64u64), + U256::from(17_000_000u64), + vec![ + U256::from(0x7fffd81u64), + U256::from(0x7fff801u64), + U256::from(0x7fff781u64), + ], + "12617929386".to_string(), + ) + .abi_encode(); + let secure = ( + U256::from(8192u64), + U256::from(17_000_000u64), + vec![ + U256::from(0x0800000000db4001u64), + U256::from(0x0800000000d54001u64), + U256::from(0x0800000000cbc001u64), + ], + "17723039943798878305460955570711717478400".to_string(), + ) + .abi_encode(); + for (slot, params, hash, id) in [ + ( + 0, + &insecure, + "0xaff065a7d6e3d8c830dfcd37c2af8a25b3dcc6cd74ba458894075e8264f1ab1e", + "0x92c8b373eb72cc3600a5a818cf8599db16e618ee3ece2dadd14f8608c1a43ac9", + ), + ( + 2, + &secure, + "0x1b2620f6a5919d5ee19a51f34026369816f479efd0404b56585ad37d31c52317", + "0xa174862efd4487031d423ca96516807775ade0191c714e513aab93d0cc289baa", + ), + ] { + assert_eq!(keccak256(params).to_string(), hash); + let config_id: B256 = id.parse().unwrap(); + assert_eq!( + bfv_crypto_config_id(params, LEGACY_BFV_CONFIG_VERSION), + config_id + ); + assert_eq!( + &request_bfv_params(slot, 0, config_id, Some(params)).unwrap(), + params + ); + assert!(request_bfv_params(slot, 0, config_id, None).is_err()); + // Slot 1 only ever carried v1 identities. + assert!(request_bfv_params(1, 0, config_id, Some(params)).is_err()); + // No current slot resolves a threshold-only identity. + for current in BfvProfile::ALL.map(BfvProfile::param_set) { + assert!(request_bfv_params(current, 0, config_id, Some(params)).is_err()); + } + } + // Slot 2 never held a v1 tuple. + let v1_id = bfv_crypto_config_id(&secure, "interfold-bfv-v1"); + assert!(request_bfv_params(2, 0, v1_id, Some(&secure)).is_err()); + } + #[test] fn mainnet_slot_one_matches_the_historical_configuration_id() { let params = ( @@ -1304,6 +1389,7 @@ mod public_key_chunk_tests { #[test] fn current_secure_slot_requires_the_current_configuration_id() { + let slot = BfvProfile::SsSecure8192.param_set(); let params = encode_bfv_params(&BfvParamSet::from(BfvPreset::SecureThreshold8192).build_arc()); for committee in CiphernodesCommitteeSize::ALL { @@ -1311,15 +1397,17 @@ mod public_key_chunk_tests { .crypto_config_id(committee) .unwrap(); assert_eq!( - request_bfv_params(2, committee as u8, id, None).unwrap(), + request_bfv_params(slot, committee as u8, id, None).unwrap(), params ); - assert!(request_bfv_params(2, (committee as u8 + 1) % 3, id, None).is_err()); - assert!(request_bfv_params(3, committee as u8, id, None).is_err()); + assert!(request_bfv_params(slot, (committee as u8 + 1) % 3, id, None).is_err()); + assert!(request_bfv_params(5, committee as u8, id, None).is_err()); + assert!(request_bfv_params(2, committee as u8, id, Some(¶ms)).is_err()); } + // A threshold-only identity is historical: no current slot admits one. let legacy_id = bfv_crypto_config_id(¶ms, LEGACY_BFV_CONFIG_VERSION); - assert_eq!(request_bfv_params(2, 0, legacy_id, None).unwrap(), params); - assert!(request_bfv_params(2, 0, keccak256(b"interfold-bfv-v1"), None).is_err()); + assert!(request_bfv_params(slot, 0, legacy_id, Some(¶ms)).is_err()); + assert!(request_bfv_params(slot, 0, keccak256(b"interfold-bfv-v1"), None).is_err()); } #[tokio::test] @@ -1450,7 +1538,7 @@ mod public_key_chunk_tests { .setRequestCrypto( U256::from(7), bfv_encryption_scheme_id(), - 2, + BfvProfile::SsSecure8192.param_set(), BfvProfile::SsSecure8192.crypto_config_id(CiphernodesCommitteeSize::Minimum)?, ) .send() diff --git a/crates/evm/indexer/tests/fixtures/fake_interfold.sol b/crates/evm/indexer/tests/fixtures/fake_interfold.sol index 68e0d02846..4657996fbd 100644 --- a/crates/evm/indexer/tests/fixtures/fake_interfold.sol +++ b/crates/evm/indexer/tests/fixtures/fake_interfold.sol @@ -38,9 +38,10 @@ contract FakeInterfold { cryptoConfigOverrides[e3Id] = configId; } + // Without an override, an E3 is a current request: parameter set 4 under the ss-insecure-64/minimum identity. function e3CryptoConfigIds(uint256 e3Id) external view returns (bytes32) { if (cryptoConfigOverrides[e3Id] != bytes32(0)) return cryptoConfigOverrides[e3Id]; - return 0x5d12098e317ec9918b099e134da06000a91d7c2bff731cc37c630b8b671a724b; + return 0xd76c4f521394e6cbe1df28036cc5dd5590c6630a403525b5c2b052f9b91507f4; } // Emit InputPublished event with passed test data @@ -89,7 +90,7 @@ contract FakeInterfold { e3Program: 0x7F3E4df648B8Cb96C1D343be976b91B97CaD5c21, decryptionVerifier: 0x4B0D8c2E5f7a6c832f8b16d3aB0e7F5d9E9B24b1, pkVerifier: 0x5C1e9D3f8A7B6c932F9C27e4Ab1F8F6e0F0C35c2, - paramSet: paramSetOverrides[_e3Id], + paramSet: cryptoConfigOverrides[_e3Id] == bytes32(0) ? 4 : paramSetOverrides[_e3Id], customParams: abi.encode("custom_params"), committeePublicKey: bytes32(keccak256("committee_public_key")), ciphertextOutput: bytes32(keccak256("encrypted_data")), diff --git a/crates/evm/runtime/src/interfold/events.rs b/crates/evm/runtime/src/interfold/events.rs index 90903718b2..b7d3b089f8 100644 --- a/crates/evm/runtime/src/interfold/events.rs +++ b/crates/evm/runtime/src/interfold/events.rs @@ -743,7 +743,7 @@ mod tests { inputWindow: [U256::ZERO; 2], encryptionSchemeId: B256::ZERO, e3Program: Address::ZERO, - paramSet: 0, + paramSet: BfvProfile::SsInsecure64.param_set(), customParams: Bytes::new(), decryptionVerifier: Address::ZERO, pkVerifier: Address::ZERO, @@ -776,7 +776,7 @@ mod tests { inputWindow: [U256::ZERO; 2], encryptionSchemeId: B256::ZERO, e3Program: Address::ZERO, - paramSet: 0, + paramSet: BfvProfile::SsInsecure64.param_set(), customParams: Bytes::new(), decryptionVerifier: Address::ZERO, pkVerifier: Address::ZERO, diff --git a/crates/state/request/src/routing/tests.rs b/crates/state/request/src/routing/tests.rs index 4084d8903d..95586e90db 100644 --- a/crates/state/request/src/routing/tests.rs +++ b/crates/state/request/src/routing/tests.rs @@ -127,7 +127,7 @@ async fn hydration_rejects_inconsistent_request_configuration_before_starting_re another_committee.crypto_config_id = BfvProfile::SsInsecure64 .crypto_config_id(CiphernodesCommitteeSize::Micro)? .into(); - // sync-insecure-64 shares registry slot 0 and the minimum committee, so its ID resolves. + // sync-insecure-64 shares the insecure slot and the minimum committee, so its ID resolves. let mut same_slot_profile = valid.clone(); same_slot_profile.crypto_config_id = BfvProfile::SyncDecInsecure64 .crypto_config_id(CiphernodesCommitteeSize::Minimum)? diff --git a/packages/interfold-contracts/contracts/Interfold.sol b/packages/interfold-contracts/contracts/Interfold.sol index 89188182f5..de30a765a5 100644 --- a/packages/interfold-contracts/contracts/Interfold.sol +++ b/packages/interfold-contracts/contracts/Interfold.sol @@ -688,7 +688,7 @@ contract Interfold is } /// @notice Registers the parameter set compiled into the active circuits. - /// @param paramSet The parameter-set index (0 = Insecure64, 2 = Secure8192). + /// @param paramSet The parameter-set index (4 = Insecure64, 3 = Secure8192). /// @param encodedParams ABI-encoded BFV parameters (degree, plaintext_modulus, moduli[]). function setParamSet( uint8 paramSet, diff --git a/packages/interfold-contracts/contracts/lib/BfvProtocol.sol b/packages/interfold-contracts/contracts/lib/BfvProtocol.sol index 0ea5d4c4da..06991dddb9 100644 --- a/packages/interfold-contracts/contracts/lib/BfvProtocol.sol +++ b/packages/interfold-contracts/contracts/lib/BfvProtocol.sol @@ -10,11 +10,11 @@ library BfvProtocol { bytes32 internal constant ENCRYPTION_SCHEME_ID = keccak256("fhe.rs:BFV"); bytes32 internal constant CIRCUIT_VERSION = keccak256("interfold-bfv-v5"); - uint8 internal constant INSECURE_PARAM_SET = 0; + uint8 internal constant INSECURE_PARAM_SET = 4; bytes32 internal constant INSECURE_PARAM_SET_HASH = 0x2898f8a9fbc317e2812695161febb2c738bf0548327f4805d0329c6f6bb3a844; - uint8 internal constant SECURE_PARAM_SET = 2; + uint8 internal constant SECURE_PARAM_SET = 3; bytes32 internal constant SECURE_PARAM_SET_HASH = 0x4f4025982214c2149028270dccc0ad45c24c2441a3496cdf1a29f5d1e1b908c3; diff --git a/packages/interfold-contracts/crypto-config.json b/packages/interfold-contracts/crypto-config.json index 7dc7740433..77f51c58f4 100644 --- a/packages/interfold-contracts/crypto-config.json +++ b/packages/interfold-contracts/crypto-config.json @@ -7,7 +7,7 @@ "presets": [ { "preset": "insecure-64", - "paramSet": 0, + "paramSet": 4, "threshold": { "name": "INSECURE_THRESHOLD_64", "degree": "64", @@ -46,7 +46,7 @@ }, { "preset": "secure-8192", - "paramSet": 2, + "paramSet": 3, "threshold": { "name": "SECURE_THRESHOLD_8192", "degree": "8192", @@ -90,7 +90,7 @@ "profile": "ss-insecure-64", "protocol": "secret-shared", "statementVersion": "interfold-bfv-v5", - "paramSet": 0, + "paramSet": 4, "threshold": { "name": "INSECURE_THRESHOLD_64", "degree": "64", @@ -139,7 +139,7 @@ "profile": "ss-secure-8192", "protocol": "secret-shared", "statementVersion": "interfold-bfv-v5", - "paramSet": 2, + "paramSet": 3, "threshold": { "name": "SECURE_THRESHOLD_8192", "degree": "8192", @@ -188,7 +188,7 @@ "profile": "sync-insecure-64", "protocol": "synchronized", "statementVersion": "interfold-bfv-v5", - "paramSet": 0, + "paramSet": 4, "threshold": { "name": "INSECURE_THRESHOLD_64", "degree": "64", diff --git a/packages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.ts b/packages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.ts index 7145c41761..cb00abc66f 100644 --- a/packages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.ts +++ b/packages/interfold-contracts/test/E3Lifecycle/E3Integration.spec.ts @@ -156,7 +156,7 @@ describe("E3 Integration - Refund/Timeout Mechanism", function () { committeeSize, inputWindow: [startTime + 100, startTime + ONE_DAY] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], @@ -1032,7 +1032,7 @@ describe("E3 Integration - Refund/Timeout Mechanism", function () { committeeSize: 0, inputWindow: [startTime, startTime + 20] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], @@ -4282,7 +4282,7 @@ describe("E3 Integration - Refund/Timeout Mechanism", function () { committeeSize: 0, inputWindow: [startTime, startTime + ONE_DAY] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], @@ -4359,7 +4359,7 @@ describe("E3 Integration - Refund/Timeout Mechanism", function () { committeeSize: 0, inputWindow: [startTime, startTime + ONE_DAY] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/E3Lifecycle/Sortition.spec.ts b/packages/interfold-contracts/test/E3Lifecycle/Sortition.spec.ts index 39cdaf2f47..cf0509f395 100644 --- a/packages/interfold-contracts/test/E3Lifecycle/Sortition.spec.ts +++ b/packages/interfold-contracts/test/E3Lifecycle/Sortition.spec.ts @@ -79,7 +79,7 @@ async function deployStack() { committeeSize: 0, inputWindow: [now + 10, now + inputWindowDuration] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/Interfold.spec.ts b/packages/interfold-contracts/test/Interfold.spec.ts index 3a4690337f..6f625ccbdd 100644 --- a/packages/interfold-contracts/test/Interfold.spec.ts +++ b/packages/interfold-contracts/test/Interfold.spec.ts @@ -234,7 +234,7 @@ describe("Interfold", function () { const { interfold, notTheOwner } = await loadFixture(setup); await expect( - interfold.connect(notTheOwner).setParamSet(0, BFV_PARAMS_DEFAULT), + interfold.connect(notTheOwner).setParamSet(4, BFV_PARAMS_DEFAULT), ) .to.be.revertedWithCustomError(interfold, "OwnableUnauthorizedAccount") .withArgs(notTheOwner); @@ -243,33 +243,36 @@ describe("Interfold", function () { it("accepts only supported circuit parameter sets", async function () { const { interfold } = await loadFixture(setup); - expect(await interfold.paramSetRegistry(0)).to.equal(BFV_PARAMS_DEFAULT); - await expect(interfold.setParamSet(2, BFV_PARAMS_SECURE)) + expect(await interfold.paramSetRegistry(4)).to.equal(BFV_PARAMS_DEFAULT); + await expect(interfold.setParamSet(3, BFV_PARAMS_SECURE)) .to.emit(interfold, "ParamSetRegistered") - .withArgs(2, BFV_PARAMS_SECURE); - expect(await interfold.paramSetRegistry(2)).to.equal(BFV_PARAMS_SECURE); - expect(await interfold.paramSetRegistry(1)).to.equal("0x"); - await expect( - interfold.setParamSet(1, BFV_PARAMS_SECURE), - ).to.be.revertedWithCustomError(interfold, "UnsupportedCryptoConfig"); - await expect(interfold.setParamSet(2, BFV_PARAMS_SECURE)) + .withArgs(3, BFV_PARAMS_SECURE); + expect(await interfold.paramSetRegistry(3)).to.equal(BFV_PARAMS_SECURE); + // Indices 0, 1 and 2 hold earlier tuples on live chains and stay closed. + for (const historical of [0, 1, 2]) { + expect(await interfold.paramSetRegistry(historical)).to.equal("0x"); + await expect( + interfold.setParamSet(historical, BFV_PARAMS_SECURE), + ).to.be.revertedWithCustomError(interfold, "UnsupportedCryptoConfig"); + } + await expect(interfold.setParamSet(3, BFV_PARAMS_SECURE)) .to.be.revertedWithCustomError(interfold, "ParamSetAlreadyRegistered") - .withArgs(2); + .withArgs(3); }); it("does not overwrite the active parameter set", async function () { const { interfold } = await loadFixture(setup); - await expect(interfold.setParamSet(0, BFV_PARAMS_DEFAULT)) + await expect(interfold.setParamSet(4, BFV_PARAMS_DEFAULT)) .to.be.revertedWithCustomError(interfold, "ParamSetAlreadyRegistered") - .withArgs(0); + .withArgs(4); }); it("rejects parameter bytes that do not match the active circuit", async function () { const { interfold } = await loadFixture(setup); await expect( - interfold.setParamSet(2, "0x"), + interfold.setParamSet(3, "0x"), ).to.be.revertedWithCustomError(interfold, "UnsupportedCryptoConfig"); }); }); @@ -556,13 +559,13 @@ describe("Interfold", function () { }); describe("request()", function () { - it("binds new secure requests to slot 2", async function () { + it("binds new secure requests to slot 3", async function () { const { interfold, request, usdcToken } = await loadFixture(setup); - await interfold.setParamSet(2, BFV_PARAMS_SECURE); + await interfold.setParamSet(3, BFV_PARAMS_SECURE); const secureRequest = { ...request, inputWindow: await freshInputWindow(), - paramSet: 2, + paramSet: 3, expectedCryptoConfigId: bfvConfiguration( "ss-secure-8192", Number(request.committeeSize), @@ -574,7 +577,7 @@ describe("Interfold", function () { interfold, "E3Requested", ); - expect((await interfold.getE3(firstE3Id)).paramSet).to.equal(2); + expect((await interfold.getE3(firstE3Id)).paramSet).to.equal(3); expect(await interfold.e3CryptoConfigIds(firstE3Id)).to.equal( secureRequest.expectedCryptoConfigId, ); @@ -630,11 +633,11 @@ describe("Interfold", function () { ]) { it(`rejects ${version} configurations for both BFV parameter sets`, async function () { const { interfold, request } = await loadFixture(setup); - await interfold.setParamSet(2, BFV_PARAMS_SECURE); + await interfold.setParamSet(3, BFV_PARAMS_SECURE); for (const [paramSet, params, currentConfigId] of [ - [0, BFV_PARAMS_DEFAULT, ACTIVE_CRYPTO_CONFIG_ID], + [4, BFV_PARAMS_DEFAULT, ACTIVE_CRYPTO_CONFIG_ID], [ - 2, + 3, BFV_PARAMS_SECURE, bfvConfiguration("ss-secure-8192", Number(request.committeeSize)) .configId, diff --git a/packages/interfold-contracts/test/Pricing/DustRotation.spec.ts b/packages/interfold-contracts/test/Pricing/DustRotation.spec.ts index e57f5fc766..0ef8fce83e 100644 --- a/packages/interfold-contracts/test/Pricing/DustRotation.spec.ts +++ b/packages/interfold-contracts/test/Pricing/DustRotation.spec.ts @@ -121,7 +121,7 @@ describe("Pricing — per-E3 dust rotation across consecutive E3s", function () number, ], e3Program: e3Program.getAddress() as unknown as string, - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [decryptionVerifier.getAddress()], @@ -140,7 +140,7 @@ describe("Pricing — per-E3 dust rotation across consecutive E3s", function () committeeSize: 0, inputWindow: [now + 10, now + inputWindowDuration] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/Pricing/Pricing.spec.ts b/packages/interfold-contracts/test/Pricing/Pricing.spec.ts index d108ac429e..0a57b6c988 100644 --- a/packages/interfold-contracts/test/Pricing/Pricing.spec.ts +++ b/packages/interfold-contracts/test/Pricing/Pricing.spec.ts @@ -467,7 +467,7 @@ describe("E3 Pricing", function () { number, ], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], @@ -571,7 +571,7 @@ describe("E3 Pricing", function () { number, ], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/Pricing/PullPaymentsAndAllowlist.spec.ts b/packages/interfold-contracts/test/Pricing/PullPaymentsAndAllowlist.spec.ts index 5d79a9c49b..2623610c7c 100644 --- a/packages/interfold-contracts/test/Pricing/PullPaymentsAndAllowlist.spec.ts +++ b/packages/interfold-contracts/test/Pricing/PullPaymentsAndAllowlist.spec.ts @@ -106,7 +106,7 @@ describe("Interfold — pull payments + fee-token allow-list", function () { committeeSize: 0, inputWindow: [now + 10, now + inputWindowDuration] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts b/packages/interfold-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts index 535483a6d1..a909931ca4 100644 --- a/packages/interfold-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts +++ b/packages/interfold-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts @@ -113,7 +113,7 @@ describe("CiphernodeRegistryOwnable", function () { committeeSize: 0, inputWindow: [currentTime + 100, currentTime + 300] as [number, number], e3Program: await mockE3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await mockDecryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/Slashing/CommitteeExpulsion.spec.ts b/packages/interfold-contracts/test/Slashing/CommitteeExpulsion.spec.ts index dcdeb87754..a4bd1e3ab8 100644 --- a/packages/interfold-contracts/test/Slashing/CommitteeExpulsion.spec.ts +++ b/packages/interfold-contracts/test/Slashing/CommitteeExpulsion.spec.ts @@ -156,7 +156,7 @@ describe("Committee Expulsion & Fault Tolerance", function () { committeeSize, inputWindow: [startTime + 100, startTime + ONE_DAY] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-contracts/test/fixtures/helpers.ts b/packages/interfold-contracts/test/fixtures/helpers.ts index 9cf45dec83..2f18693874 100644 --- a/packages/interfold-contracts/test/fixtures/helpers.ts +++ b/packages/interfold-contracts/test/fixtures/helpers.ts @@ -189,7 +189,7 @@ export interface BuildRequestParamsOptions { windowDuration?: number; /** Override custom params bytes. Defaults to an ABI-encoded throwaway address. */ customParams?: string; - /** Param-set id registered on the Interfold. Defaults to `0`. */ + /** Param-set id registered on the Interfold. Defaults to `4` (insecure-64). */ paramSet?: number; } @@ -215,7 +215,7 @@ export const buildRequestParams = async ( committeeSize: opts.committeeSize ?? COMMITTEE_SIZE_MINIMUM, inputWindow: [now + startOffset, now + windowDuration] as [number, number], e3Program: e3ProgramAddr, - paramSet: opts.paramSet ?? 0, + paramSet: opts.paramSet ?? 4, computeProviderParams: abiCoder.encode( ["address"], [decryptionVerifierAddr], diff --git a/packages/interfold-contracts/test/fixtures/system.ts b/packages/interfold-contracts/test/fixtures/system.ts index a5488714bc..8b3e636e96 100644 --- a/packages/interfold-contracts/test/fixtures/system.ts +++ b/packages/interfold-contracts/test/fixtures/system.ts @@ -553,7 +553,7 @@ export async function deployInterfoldSystem( if (!(await interfold.e3Programs(await e3Program.getAddress()))) { await interfold.registerE3Program(await e3Program.getAddress()); } - await interfold.setParamSet(0, BFV_PARAMS_DEFAULT); + await interfold.setParamSet(4, BFV_PARAMS_DEFAULT); await interfold.setDecryptionVerifier( ENCRYPTION_SCHEME_ID, await decryptionVerifier.getAddress(), @@ -618,7 +618,7 @@ export async function deployInterfoldSystem( committeeSize: COMMITTEE_SIZE_MINIMUM, inputWindow: [now + 10, now + inputWindowDuration] as [number, number], e3Program: await e3Program.getAddress(), - paramSet: 0, + paramSet: 4, computeProviderParams: abiCoder.encode( ["address"], [await decryptionVerifier.getAddress()], diff --git a/packages/interfold-sdk/src/contracts/types.ts b/packages/interfold-sdk/src/contracts/types.ts index 919e95e3e0..1b4cf4e12f 100644 --- a/packages/interfold-sdk/src/contracts/types.ts +++ b/packages/interfold-sdk/src/contracts/types.ts @@ -33,8 +33,8 @@ export function validateCommitteeSize(value: number | CommitteeSize): CommitteeS } export enum ParamSet { - Insecure64 = 0, - Secure8192 = 2, + Insecure64 = 4, + Secure8192 = 3, } export interface E3 { diff --git a/scripts/circuits/bfv-bindings.test.ts b/scripts/circuits/bfv-bindings.test.ts index 825013bbfd..1a99eb56a8 100644 --- a/scripts/circuits/bfv-bindings.test.ts +++ b/scripts/circuits/bfv-bindings.test.ts @@ -126,7 +126,7 @@ test('generated parameters retain independent ABI and configuration-ID vectors', vector.cryptoConfigId, ) } - assert.equal(bfvPresetForParamSet(1), undefined) + for (const historical of [0, 1, 2]) assert.equal(bfvPresetForParamSet(historical), undefined) assert.equal(bfvPresetForParamSet(256), undefined) assert.equal(bfvPresetForParamSet('0' as unknown as number), undefined) assert.deepEqual(BFV_PARAMS.insecure64, BFV_PRESETS['insecure-64'].threshold) @@ -464,13 +464,13 @@ test('the packed BFV subpath builds browser-targeted bundles, ESM, CJS, and decl execFileSync('tar', ['-xzf', join(temp, archive), '--strip-components=1', '-C', installed]) const profiles = JSON.parse(readFileSync(join(root, 'crates/bfv/params/tests/fixtures/bfv_profiles.json'), 'utf8')) const secure = profiles.profiles.find((v: { profile: string }) => v.profile === 'ss-secure-8192') - const check = `if (bfv.bfvConfiguration('ss-secure-8192', 0).configId !== ${JSON.stringify(secure.configurations[0].cryptoConfigId)}) throw new Error('wrong ID'); if (typeof bfv.bfvPresetForParamSet(2).threshold.degree !== 'bigint') throw new Error('lost integer type'); if (bfv.decryptionAggregatorLayout(4).publicInputsLength !== 73) throw new Error('wrong layout');` + const check = `if (bfv.bfvConfiguration('ss-secure-8192', 0).configId !== ${JSON.stringify(secure.configurations[0].cryptoConfigId)}) throw new Error('wrong ID'); if (typeof bfv.bfvPresetForParamSet(3).threshold.degree !== 'bigint') throw new Error('lost integer type'); if (bfv.decryptionAggregatorLayout(4).publicInputsLength !== 73) throw new Error('wrong layout');` execFileSync(process.execPath, ['--input-type=module', '-e', `import * as bfv from '@interfold/contracts/bfv'; ${check}`], { cwd: temp, stdio: 'pipe', }) execFileSync(process.execPath, ['-e', `const bfv = require('@interfold/contracts/bfv'); ${check}`], { cwd: temp, stdio: 'pipe' }) - const consumer = `const degree: bigint = bfv.bfvPresetForParamSet(2)!.threshold.degree; const id: \`0x\${string}\` = bfv.bfvConfiguration('ss-secure-8192', 0).configId; void degree; void id; + const consumer = `const degree: bigint = bfv.bfvPresetForParamSet(3)!.threshold.degree; const id: \`0x\${string}\` = bfv.bfvConfiguration('ss-secure-8192', 0).configId; void degree; void id; // @ts-expect-error unknown preset keys are not supported bfv.BFV_PRESETS.missing; // @ts-expect-error unknown profile names are not supported From 6d0c351ccf47944c46403b5dc7f428b7b78daa96 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:10:10 +0000 Subject: [PATCH 2/8] docs: describe the parameter-set re-index and its cutover procedure - upgrades.md replaces the unresolved registry-index gap with the cutover procedure: register index 3 (secure) and index 4 (insecure, testnets) in the paused governance batch, check the exact bytes before resume, and keep indices 0, 1 and 2 as historical registry reads. - The developer pages, the committee-selection note and the SDK README name indices 3 and 4. --- docs/architecture/committee-selection.md | 3 +- docs/architecture/upgrades.md | 64 +++++++++++-------- docs/pages/build/best-practices.mdx | 2 +- .../build/e3-program/complete-example.mdx | 2 +- .../pages/build/e3-program/secure-process.mdx | 12 ++-- docs/pages/build/interfold-contract.mdx | 2 +- docs/pages/build/quick-start.mdx | 4 +- docs/pages/build/requesting-an-e3.mdx | 16 ++--- docs/pages/build/sdk.mdx | 4 +- .../build/tutorials/custom-zk-circuits.mdx | 2 +- .../build/tutorials/deploy-to-testnet.mdx | 4 +- docs/pages/internals/dkg.mdx | 4 +- docs/pages/learn/cryptography.mdx | 4 +- packages/interfold-sdk/README.md | 4 +- 14 files changed, 70 insertions(+), 57 deletions(-) diff --git a/docs/architecture/committee-selection.md b/docs/architecture/committee-selection.md index 4293925a61..8f9e110fab 100644 --- a/docs/architecture/committee-selection.md +++ b/docs/architecture/committee-selection.md @@ -37,7 +37,8 @@ matching artifacts and contracts. Requests and saved contexts must retain the id their selected profile; shared threshold bytes do not authorize profile substitution. Confirmed-chain ingestion resolves the exact request identity. Synchronized profiles and older threshold-only identities are not admitted. [Upgrades](upgrades.md) preserves historical -parameter-set index 1 and new secure index 2; never reinterpret old requests. +parameter-set indices 0, 1 and 2 and registers the current tuples at indices 3 and 4; never +reinterpret old requests. Recovery re-derives the profile/committee identity and requires the exact threshold parameter bytes before metadata seeds restored work. Recovered local selections must also agree with the hydrated diff --git a/docs/architecture/upgrades.md b/docs/architecture/upgrades.md index 613860d838..553c2ce96f 100644 --- a/docs/architecture/upgrades.md +++ b/docs/architecture/upgrades.md @@ -78,16 +78,15 @@ decryption features compiled but synchronized profile admission disabled. Node, IDs, circuit archives, and OpenVM guest/receipt identity must match; v1–v4 requests cannot be treated as v5. Runtime/SDK tooling reject old configuration IDs for new requests. -**Mainnet parameter-set index 1 remains the previous secure tuple.** Register the new secure tuple -at index **2** in the paused/drained governance batch; never overwrite/reinterpret old E3 records. -Validate its exact bytes before resume. Current nodes/request clients reject index 1. Indexer -current index-0/index-2 keys use local v5 parameters; historical index-0/index-1 v1 keys use -append-only registry bytes checked against frozen crypto ID. Other unsupported IDs are skipped -without storing keys so catch-up can reach supported rounds. +**Mainnet parameter-set index 1 remains the previous secure tuple.** v0.19 registered its secure +tuple at index **2** in the paused/drained governance batch; never overwrite/reinterpret old E3 +records. Validate the exact bytes before resume. The [n = 45 re-index](#bfv-profile-cutover) makes +indices 0, 1 and 2 historical and sets the current indices. Unsupported IDs are skipped without +storing keys so catch-up can reach supported rounds. `upgrade:v19` / `scripts/upgrade/v19Cutover.ts prepare` deploys linked Interfold implementation and -BFV routes, then prepares one batch: upgrade Interfold; register missing index 2/thresholds; install -PK/decryption routers/OpenVM ciphertext verifier; register/bind new CRISP and retire earlier +BFV routes, then prepares one batch: upgrade Interfold; register missing secure index/thresholds; +install PK/decryption routers/OpenVM ciphertext verifier; register/bind new CRISP and retire earlier programs; require protocol 8/generation 2; keep paused. Mainnet requires `--openvm-identity`. Preparation verifies drain/pause, records against live implementation, CRISP owner/binding, common image/receipt identity, guest commitments, Halo2 runtime hash, Avail bridge/windows, and signer. @@ -264,18 +263,31 @@ published archives or reuse unqualified deployment bindings. The n = 45 parameter-search slice, unlike the profile slice above, changes SS threshold parameter bytes: the `error1_variance` of both threshold tuples, so their hashes, every profile configuration -ID, and every verification key and verifier. DKG tuples are unchanged. The tuples keep registry -indices 0 and 2. **Unresolved gap; it needs a human rollout decision before release.** `setParamSet` -is append-only, and live registries already hold the v0.19 tuples at those indices: Mainnet index 2 -(`0x1b2620f6…2317`), Sepolia index 0 (`0xaff065a7…ab1e`) and index 2 (`0x1b2620f6…2317`). Such a -deployment cannot register the new bytes in place. `requestE3` does not compare the registered bytes -with the `BfvProtocol` hash, so after an in-place upgrade it binds the old bytes under a new -configuration ID while nodes prove with the new tuple. The indexer derives the threshold-only v5 ID -of indices 0 and 2 from the local tuple, so it also stops reading v0.19 E3s at those indices. This -breaks the [v0.19 rule](#v019-protocolcrypto-cutover) never to overwrite or reinterpret old E3 -records. Either deploy a new stack, or, as v0.19 did for index 1, register the new tuples at new -indices and keep indices 0 and 2 as historical registry-byte reads with frozen v5 IDs and fixture -vectors. +ID, and every verification key and verifier. DKG tuples are unchanged. **The tuples move to new +registry indices: secure-8192 to index 3 and insecure-64 to index 4.** `setParamSet` is append-only, +and live registries hold earlier tuples at indices 0–2: Mainnet index 0 (`0x18c6d865…7b4f`, +degree-512 v1), index 1 (`0xd7068fdc…43ec`, v1 secure) and index 2 (`0x1b2620f6…2317`, v0.19 +secure); Sepolia index 0 (`0xaff065a7…ab1e`, v0.19 insecure) and index 2 (`0x1b2620f6…2317`). +Indices 3 and 4 are empty on both. Reusing an index is not possible and would not be safe: +`setParamSet` reverts `ParamSetAlreadyRegistered`, and `requestE3` does not compare the registered +bytes with the `BfvProtocol` hash, so it would hand the old bytes to the E3 program and bind their +hash for the ciphertext verifier while nodes prove with the new tuple. + +Cutover procedure, in the paused/drained governance batch that upgrades Interfold and its linked +`ActiveCryptoConfig`: call `setParamSet(3, …)` with the secure tuple on Mainnet and Sepolia, and +`setParamSet(4, …)` with the insecure tuple on Sepolia. A fresh deployment registers both through +`registerActiveBfvParamSet`. `upgrade:v19` prepares only the secure index; a Sepolia batch must add +index 4. Before resume, check that `keccak256(paramSetRegistry(3))` is +`BfvProtocol.SECURE_PARAM_SET_HASH` (`0x4f402598…08c3`), that `keccak256(paramSetRegistry(4))` is +`INSECURE_PARAM_SET_HASH` (`0x2898f8a9…a844`), and that indices 0, 1 and 2 still hold the bytes +above. Never overwrite or reinterpret indices 0, 1 and 2. After the upgrade `getE3Quote` and +`request` revert `UnsupportedCryptoConfig` for them, and nodes skip any request event that names +them. Clients derive the index from the profile (`ParamSet` in `@interfold/sdk`, +`BFV_PRESETS[…].paramSet` in `@interfold/contracts`); a client that hard-codes 0 or 2, such as the +CRISP server `E3_PARAM_SET`, must change with the release. The indexer resolves indices 3 and 4 only +through a current profile identity. It reads indices 0, 1 and 2 from the append-only registry bytes +and accepts only the frozen threshold-only ID of those exact bytes: v5 at indices 0 and 2, v1 at +indices 0 and 1. `crates/bfv/params/tests/fixtures/bfv_protocol.json` freezes these vectors. The DKG runtime slice changes local C1/C2/C4 and native-generation request/response encodings, `ThresholdSharePending` (optional SS lane plus encrypted own rows), and keyshare recovery (optional @@ -478,12 +490,12 @@ and older lack keyshare guards. ### Insecure testnet preset reset `InsecureThreshold64` and `InsecureDkg64` occupy persisted `BfvPreset` discriminants 0 and 1. -On-chain parameter-set index 0 carries the degree-64 tuple. Degree-512 stores used the same -discriminants under schema 8, so the schema marker cannot reject them. Before starting against a -fresh testnet stack, testnet nodes must run `interfold node reset-data` under the guards below. -Redeploy a testnet that holds degree-512 index-0 E3s; do not upgrade it in place or reinterpret -those E3s with degree-64 parameters. This requirement does not replace mainnet's secure index-2 -cutover procedure. +On-chain parameter-set index 4 carries the current degree-64 tuple; index 0 keeps the earlier +insecure tuples. Degree-512 stores used the same discriminants under schema 8, so the schema marker +cannot reject them. Before starting against a fresh testnet stack, testnet nodes must run +`interfold node reset-data` under the guards below. Redeploy a testnet that holds degree-512 index-0 +E3s; do not upgrade it in place or reinterpret those E3s with degree-64 parameters. This requirement +does not replace the [parameter-set re-index](#bfv-profile-cutover) cutover procedure. ### Identity and active-state guards diff --git a/docs/pages/build/best-practices.mdx b/docs/pages/build/best-practices.mdx index 651e1ed488..f3dc2d3091 100644 --- a/docs/pages/build/best-practices.mdx +++ b/docs/pages/build/best-practices.mdx @@ -20,7 +20,7 @@ checklist. - **Choose a supported committee size.** The committee enum fixes N, H, and T in `lib/ActiveCryptoConfig.sol`. On mainnet, the launch pricing sets `minCommitteeSize` to 19, so only `Small` is accepted. `getE3Quote` reverts with `CommitteeSizeTooSmall` for a smaller size. -- **Use the secure parameter set for private data.** Version-7 mainnet accepts only `paramSet` 2 +- **Use the secure parameter set for private data.** Mainnet accepts only `paramSet` 3 (secure-8192). The insecure-64 preset has no production security. - **Match the SDK preset to the parameter set.** The SDK does not compare them. A mismatch encrypts inputs under the wrong parameters. diff --git a/docs/pages/build/e3-program/complete-example.mdx b/docs/pages/build/e3-program/complete-example.mdx index 4da8a479b4..8645614a02 100644 --- a/docs/pages/build/e3-program/complete-example.mdx +++ b/docs/pages/build/e3-program/complete-example.mdx @@ -103,7 +103,7 @@ the ciphernodes with `interfold nodes up`. ### Request the E3 In the client, `client/src/pages/steps/RequestComputation.tsx` builds the request. It uses committee -size `0` (`Minimum`), parameter set `0`, and an input window. The window opens 15 seconds after the +size `0` (`Minimum`), parameter set `4`, and an input window. The window opens 15 seconds after the current chain time and lasts 100 seconds. It calls `getE3Quote`, `approveFeeToken`, and `requestE3` from the SDK. diff --git a/docs/pages/build/e3-program/secure-process.mdx b/docs/pages/build/e3-program/secure-process.mdx index dac8290f00..08549128fa 100644 --- a/docs/pages/build/e3-program/secure-process.mdx +++ b/docs/pages/build/e3-program/secure-process.mdx @@ -98,16 +98,16 @@ Keccak-256 hash. The proof must carry the same parameter hash. See | `paramSet` | Preset | Degree | Plaintext modulus | Ciphertext moduli | | ---------- | --------------------- | ------ | ----------------- | ----------------- | -| `0` | `InsecureThreshold64` | 64 | 17000000 | 3 | -| `2` | `SecureThreshold8192` | 8192 | 17000000 | 3 | +| `4` | `InsecureThreshold64` | 64 | 17000000 | 3 | +| `3` | `SecureThreshold8192` | 8192 | 17000000 | 3 | Sources: `BfvPreset::from_on_chain_param_set` in `crates/bfv/params/src/presets.rs` and the preset constants in `crates/bfv/params/src/constants.rs`. - Parameter set `0` is insecure. It exists for local development and tests. The template client + Parameter set `4` is insecure. It exists for local development and tests. The template client requests it (`profile: 'ss-insecure-64'` in `client/src/pages/steps/RequestComputation.tsx`). Use - parameter set `2` for real data. + parameter set `3` for real data. ## Processor output @@ -243,8 +243,8 @@ Other limits: 10,000,000 + 8,000,000 decrypts to 1,000,000. - Each preset has an addition budget, `z` (`SEARCH_Z` in `crates/bfv/params/src/constants.rs`). The ciphernodes make the smudging noise of their decryption shares large enough for an output of at - most `z` fresh ciphertexts added together. `z` is 100,000 for parameter set `2` and for parameter - set `0`. With a larger sum, the smudging noise protects the secret key shares with less + most `z` fresh ciphertexts added together. `z` is 100,000 for parameter set `3` and for parameter + set `4`. With a larger sum, the smudging noise protects the secret key shares with less statistical security than the preset specifies. A product with a plaintext also increases the noise, and `z` does not count it. - The processor returns `Vec`, not a `Result`. An `unwrap` that fails panics. Inside the zkVM a diff --git a/docs/pages/build/interfold-contract.mdx b/docs/pages/build/interfold-contract.mdx index 02fa1b38d9..eb7c9538c2 100644 --- a/docs/pages/build/interfold-contract.mdx +++ b/docs/pages/build/interfold-contract.mdx @@ -79,7 +79,7 @@ spend the quoted fee in the fee token. For the fee formula and the refund rules, | `committeeSize` | `CommitteeSize` (`uint8`) | `Minimum` (0), `Micro` (1), or `Small` (2). | The size must have thresholds configured. The pricing minimums must accept it. | | `inputWindow` | `uint256[2]` | Start and end timestamps of the input window, in seconds. | The start must not be in the past. The end must not be before the start. | | `e3Program` | `IE3Program` | The E3 program contract. | The contract owner must register the program first. | -| `paramSet` | `uint8` | BFV parameter set. `0` is insecure-64, `2` is secure-8192. | The chain must support the set, and the set must be registered. | +| `paramSet` | `uint8` | BFV parameter set. `4` is insecure-64, `3` is secure-8192. | The chain must support the set, and the set must be registered. | | `computeProviderParams` | `bytes` | Compute provider settings. | Interfold passes the bytes to `e3Program.validate`. | | `customParams` | `bytes` | Application settings. | Interfold stores the bytes on the E3 and passes them to `e3Program.validate`. | | `expectedFeeToken` | `IERC20` | The fee token that the requester accepts. | Must equal `feeToken()`. Otherwise the call reverts with `FeeTokenChanged`. | diff --git a/docs/pages/build/quick-start.mdx b/docs/pages/build/quick-start.mdx index b31eb8246b..f11757c8ed 100644 --- a/docs/pages/build/quick-start.mdx +++ b/docs/pages/build/quick-start.mdx @@ -181,7 +181,7 @@ The Interfold contract records each E3 in a sequence of stages. Your E3 went thr -The client requested an E3 with the `minimum` committee size and parameter set `0` (`insecure-64`). +The client requested an E3 with the `minimum` committee size and parameter set `4` (`insecure-64`). @@ -208,7 +208,7 @@ The committee decrypted the sum with T + 1 = 2 decryption shares. The plaintext | Stage | What happened in the template | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Requested` | The client got a fee quote, approved the fee token, and called the Interfold contract. The request used the `minimum` committee size, parameter set `0` (`insecure-64`), and an input window of 100 seconds that opens 15 seconds after the request. The contract emitted `E3Requested`. | +| `Requested` | The client got a fee quote, approved the fee token, and called the Interfold contract. The request used the `minimum` committee size, parameter set `4` (`insecure-64`), and an input window of 100 seconds that opens 15 seconds after the request. The contract emitted `E3Requested`. | | `CommitteeFinalized` | Sortition selected three of the five ciphernodes. The `minimum` committee has N = 3 and threshold T = 1. The `CHAIN` process supplied the randomness that sortition needs on the local chain. The contract emitted `CommitteeFinalized`. | | `KeyPublished` | The committee ran distributed key generation (DKG) and published one public key. The client assembled the key from `CommitteePublicKeyChunkPublished` events and checked it against the key commitment. Then it encrypted each number and called `MyProgram.publishInput` twice. | | `CiphertextReady` | When the input window closed, the coordination server sent the two ciphertexts to the program server. The program server ran `fhe_processor` and returned the encrypted sum. The coordination server called `publishCiphertextOutput`, and the contract emitted `CiphertextOutputReferencePublished`. | diff --git a/docs/pages/build/requesting-an-e3.mdx b/docs/pages/build/requesting-an-e3.mdx index 1ff05fe986..fdde4175d1 100644 --- a/docs/pages/build/requesting-an-e3.mdx +++ b/docs/pages/build/requesting-an-e3.mdx @@ -309,26 +309,26 @@ The parameter set selects the BFV parameters. The SDK preset must match it. | `paramSet` | SDK preset name | Ring degree | Use | | ---------- | ----------------------- | ----------- | ------------------------------------------ | -| 0 | `INSECURE_THRESHOLD_64` | 64 | Tests only. It has no production security. | -| 2 | `SECURE_THRESHOLD_8192` | 8192 | Production. | +| 4 | `INSECURE_THRESHOLD_64` | 64 | Tests only. It has no production security. | +| 3 | `SECURE_THRESHOLD_8192` | 8192 | Production. | Each network accepts different pairs: | Network | Parameter sets | Committee sizes | | -------------------------------------- | -------------- | ----------------------------------------------------------------- | -| Ethereum mainnet | 2 only | `Small` only. The launch pricing sets `minCommitteeSize` to 19. | -| Sepolia, local chains (31337 and 1337) | 0 and 2 | All three sizes, when the deployment configures their thresholds. | +| Ethereum mainnet | 3 only | `Small` only. The launch pricing sets `minCommitteeSize` to 19. | +| Sepolia, local chains (31337 and 1337) | 3 and 4 | All three sizes, when the deployment configures their thresholds. | A parameter set must also be registered on the chain. `paramSetRegistry(paramSet)` returns empty bytes for an unregistered set. The local deploy script registers the set of the active circuit build -(set 0 in the checked-in configuration). With mock verifiers, it configures thresholds for all three +(set 4 in the checked-in configuration). With mock verifiers, it configures thresholds for all three sizes. With `ENABLE_ZK_VERIFICATION=true`, it configures thresholds only for the committee of the -active circuit build, because its verifiers check only that committee. Mainnet retains index 1 for -older E3s; version-7 requests use index 2. +active circuit build, because its verifiers check only that committee. Indices 0, 1, and 2 stay in +the registry for older E3s; new requests use index 3 or 4. Use these rules to choose: -- Choose `paramSet` 2 for any value that must stay private. +- Choose `paramSet` 3 for any value that must stay private. - Choose a larger committee for more fault tolerance. It costs more. - Make sure that the network has enough eligible ciphernodes and bond owners. The request reverts when fewer than N are available. diff --git a/docs/pages/build/sdk.mdx b/docs/pages/build/sdk.mdx index 61b814f93d..7b4f7941de 100644 --- a/docs/pages/build/sdk.mdx +++ b/docs/pages/build/sdk.mdx @@ -172,8 +172,8 @@ of the E3 request, which also sets the `paramSet` of the E3. | Preset name | Request `profile` | `paramSet` | Ring degree | CRT moduli (L) | Use | | ----------------------- | ----------------- | ---------- | ----------- | -------------- | ------------------------------- | -| `INSECURE_THRESHOLD_64` | `ss-insecure-64` | 0 | 64 | 3 | Local development and tests | -| `SECURE_THRESHOLD_8192` | `ss-secure-8192` | 2 | 8192 | 3 | Production and secure test runs | +| `INSECURE_THRESHOLD_64` | `ss-insecure-64` | 4 | 64 | 3 | Local development and tests | +| `SECURE_THRESHOLD_8192` | `ss-secure-8192` | 3 | 8192 | 3 | Production and secure test runs | The insecure preset has no production security. Use it only for tests. `ThresholdBfvParamsPresetNames` lists both names, and `DEFAULT_THRESHOLD_BFV_PARAMS_PRESET_NAME` is diff --git a/docs/pages/build/tutorials/custom-zk-circuits.mdx b/docs/pages/build/tutorials/custom-zk-circuits.mdx index f0926a5fbb..19af9758aa 100644 --- a/docs/pages/build/tutorials/custom-zk-circuits.mdx +++ b/docs/pages/build/tutorials/custom-zk-circuits.mdx @@ -101,7 +101,7 @@ Add a `circuits` directory to the project. The verifier goes in `contracts/verif ### Write the input circuit Create `circuits/binary_input/Nargo.toml`. The library at `v0.18.0` uses the `insecure-64` preset, -which the template requests (`paramSet: 0`). +which the template requests (`profile: 'ss-insecure-64'`). ```toml filename="circuits/binary_input/Nargo.toml" [package] diff --git a/docs/pages/build/tutorials/deploy-to-testnet.mdx b/docs/pages/build/tutorials/deploy-to-testnet.mdx index 5f17a3f888..a671d91e89 100644 --- a/docs/pages/build/tutorials/deploy-to-testnet.mdx +++ b/docs/pages/build/tutorials/deploy-to-testnet.mdx @@ -395,8 +395,8 @@ pnpm dev The client requests E3s with `profile: 'ss-insecure-64'`, and the SDK uses `INSECURE_THRESHOLD_64` by default (`VITE_THRESHOLD_BFV_PARAMS_PRESET_NAME`). Keep the two values in agreement. Sepolia -accepts the param sets 0 (`insecure-64`) and 2 (`secure-8192`) when registered. Do not submit -private data with the insecure preset. Version-7 mainnet requests use index 2; index 1 remains for +accepts the param sets 4 (`insecure-64`) and 3 (`secure-8192`) when registered. Do not submit +private data with the insecure preset. Mainnet requests use index 3; indices 0, 1, and 2 remain for older E3s. The SDK does not include secure-8192 proof circuits. Compile matching circuits for secure proofs; see [SDK encryption proofs](/build/sdk#encryption-proofs). diff --git a/docs/pages/internals/dkg.mdx b/docs/pages/internals/dkg.mdx index f475ae049d..de6940be1f 100644 --- a/docs/pages/internals/dkg.mdx +++ b/docs/pages/internals/dkg.mdx @@ -850,8 +850,8 @@ the party at fault. ## BFV parameter presets -`crates/bfv/params/src/constants.rs` defines the presets. Version-7 E3 requests use `paramSet` 0 for -`insecure-64` and 2 for `secure-8192`. Index 1 remains in the registry for older E3s. +`crates/bfv/params/src/constants.rs` defines the presets. E3 requests use `paramSet` 4 for +`insecure-64` and 3 for `secure-8192`. Indices 0, 1, and 2 remain in the registry for older E3s. | Parameter | `insecure-64` | `secure-8192` | | ---------------------------------------- | -------------------------------- | ------------- | diff --git a/docs/pages/learn/cryptography.mdx b/docs/pages/learn/cryptography.mdx index 77d09cbef2..5f5a86514e 100644 --- a/docs/pages/learn/cryptography.mdx +++ b/docs/pages/learn/cryptography.mdx @@ -261,8 +261,8 @@ set for the individual keys. The values come from `crates/bfv/params/src/constan | Preset | `paramSet` | Threshold degree | Threshold CRT moduli | Plaintext modulus $t$ | DKG degree | DKG CRT moduli | | ------------- | ---------: | ---------------: | -------------------: | --------------------: | ---------: | -------------: | -| `insecure-64` | 0 | 64 | 3 | 17,000,000 | 64 | 2 | -| `secure-8192` | 2 | 8192 | 3 | 17,000,000 | 8192 | 2 | +| `insecure-64` | 4 | 64 | 3 | 17,000,000 | 64 | 2 | +| `secure-8192` | 3 | 8192 | 3 | 17,000,000 | 8192 | 2 | `insecure-64` is for development and tests only. The code marks it as not for production. The deployment script refuses to deploy it on a chain that is not a known test or local chain. diff --git a/packages/interfold-sdk/README.md b/packages/interfold-sdk/README.md index a81a7ac7ea..74d29c11b1 100644 --- a/packages/interfold-sdk/README.md +++ b/packages/interfold-sdk/README.md @@ -494,8 +494,8 @@ on-chain `paramSet` index registered in the Interfold contract: | Preset name | On-chain `paramSet` index | Use case | | ------------------------- | ------------------------- | ------------------------------------------------------------------------ | -| `'INSECURE_THRESHOLD_64'` | `0` | Fast local or testnet work. This preset is not cryptographically secure. | -| `'SECURE_THRESHOLD_8192'` | `2` | Production-equivalent work with degree 8192 and three ciphertext moduli. | +| `'INSECURE_THRESHOLD_64'` | `4` | Fast local or testnet work. This preset is not cryptographically secure. | +| `'SECURE_THRESHOLD_8192'` | `3` | Production-equivalent work with degree 8192 and three ciphertext moduli. | | Network | Supported presets | | ----------------- | ------------------------------------------------------- | From 5cf87a7bbb5949f3167790437e7995ebc1503830 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:26:23 +0000 Subject: [PATCH 3/8] fix(contracts): register every chain parameter set in the v0.19 cutover batch - `upgrade:v19 prepare` registered only the secure index 3, and `validate` checked only that index. Sepolia requests default to the insecure index 4, so a resumed Sepolia would reject them with "BFV param set not registered". - `prepare` now adds one `setParamSet` call for each parameter set of the chain that the registry lacks, and stops if an index holds other bytes. - `validate`, and `resume` through it, check every parameter set of the chain. - The plan records `paramSetsRegisteredByBatch` in place of `paramSet` and `paramSetRegisteredByBatch`. - The cutover test uses index 3 and covers a batch that registers two sets. --- docs/architecture/upgrades.md | 6 +- .../scripts/protocol/types.ts | 5 +- .../scripts/upgrade/v19Cutover.ts | 75 ++++++++++--------- .../test/Deployment/V19Cutover.spec.ts | 22 +++++- 4 files changed, 65 insertions(+), 43 deletions(-) diff --git a/docs/architecture/upgrades.md b/docs/architecture/upgrades.md index 553c2ce96f..1c3ca5e996 100644 --- a/docs/architecture/upgrades.md +++ b/docs/architecture/upgrades.md @@ -85,7 +85,7 @@ indices 0, 1 and 2 historical and sets the current indices. Unsupported IDs are storing keys so catch-up can reach supported rounds. `upgrade:v19` / `scripts/upgrade/v19Cutover.ts prepare` deploys linked Interfold implementation and -BFV routes, then prepares one batch: upgrade Interfold; register missing secure index/thresholds; +BFV routes, then prepares one batch: upgrade Interfold; register missing param sets/thresholds; install PK/decryption routers/OpenVM ciphertext verifier; register/bind new CRISP and retire earlier programs; require protocol 8/generation 2; keep paused. Mainnet requires `--openvm-identity`. Preparation verifies drain/pause, records against live implementation, CRISP owner/binding, common @@ -276,8 +276,8 @@ hash for the ciphertext verifier while nodes prove with the new tuple. Cutover procedure, in the paused/drained governance batch that upgrades Interfold and its linked `ActiveCryptoConfig`: call `setParamSet(3, …)` with the secure tuple on Mainnet and Sepolia, and `setParamSet(4, …)` with the insecure tuple on Sepolia. A fresh deployment registers both through -`registerActiveBfvParamSet`. `upgrade:v19` prepares only the secure index; a Sepolia batch must add -index 4. Before resume, check that `keccak256(paramSetRegistry(3))` is +`registerActiveBfvParamSet`. `upgrade:v19` prepares each index that the chain lacks, and its +`validate` checks them. Before resume, check that `keccak256(paramSetRegistry(3))` is `BfvProtocol.SECURE_PARAM_SET_HASH` (`0x4f402598…08c3`), that `keccak256(paramSetRegistry(4))` is `INSECURE_PARAM_SET_HASH` (`0x2898f8a9…a844`), and that indices 0, 1 and 2 still hold the bytes above. Never overwrite or reinterpret indices 0, 1 and 2. After the upgrade `getE3Quote` and diff --git a/packages/interfold-contracts/scripts/protocol/types.ts b/packages/interfold-contracts/scripts/protocol/types.ts index 8a5c1e606b..5294caf851 100644 --- a/packages/interfold-contracts/scripts/protocol/types.ts +++ b/packages/interfold-contracts/scripts/protocol/types.ts @@ -328,9 +328,8 @@ export interface V19CutoverPlan { }; nodeReleasePolicyUpdated: boolean; cryptoConfigId: string; - paramSet: number; - /** The batch registers the parameter set, which the chain does not hold yet. */ - paramSetRegisteredByBatch: boolean; + /** The parameter-set indices that the batch registers; the chain already holds the others. */ + paramSetsRegisteredByBatch: number[]; pkVerifier: string; decryptionVerifier: string; bfvVerifierRoutes: BfvVerifierRouteDeployment[]; diff --git a/packages/interfold-contracts/scripts/upgrade/v19Cutover.ts b/packages/interfold-contracts/scripts/upgrade/v19Cutover.ts index 9dddd9b56b..446587cf48 100644 --- a/packages/interfold-contracts/scripts/upgrade/v19Cutover.ts +++ b/packages/interfold-contracts/scripts/upgrade/v19Cutover.ts @@ -2,7 +2,7 @@ // // The v0.19 cutover. Requests are paused and every E3 and committee is drained. One governance // batch then upgrades Interfold (new libraries, because `ActiveCryptoConfig` changed), registers -// the secure BFV parameter set, installs the BFV verifier routers, wires the OpenVM CRISP program, +// the BFV parameter sets, installs the BFV verifier routers, wires the OpenVM CRISP program, // retires the earlier programs and raises the node-release policy. Requests stay paused until // `resume` builds the unpause batch. // @@ -21,6 +21,7 @@ import fs from "node:fs"; import path from "node:path"; import { pathToFileURL } from "node:url"; +import { BFV_PRESETS } from "../../bfv.js"; import { assertRefreshedOwnerCapacity } from "../../tasks/committeeCapacity"; import { Interfold__factory as InterfoldFactory, @@ -32,7 +33,7 @@ import { availVectorXForChain, } from "../dataAvailability"; import { arg, connect, hasFlag, networkName } from "../protocol/cli"; -import { BFV_PARAMS, ZERO, proxyAdminInterface } from "../protocol/constants"; +import { ZERO, proxyAdminInterface } from "../protocol/constants"; import { deployBfvVerifierRoutes } from "../protocol/deployContracts"; import { crispDeploymentsPath, @@ -74,6 +75,7 @@ import { PRODUCTION_BFV_CONFIG, activeBfvConfigForChain, bfvConfigsForChain, + bfvParamSetConfigsForChain, } from "../utils"; import { equalAddress, @@ -87,9 +89,18 @@ import { } from "./safeProxyUpgrade"; export const BFV_SCHEME_ID = ethersLib.id("fhe.rs:BFV"); -const SECURE_PARAM_SET = PRODUCTION_BFV_CONFIG.paramSet; const SUPPORTED_CHAINS = [1, 11155111, 31337]; +/** The parameter sets that requests on `chainId` use, as `setParamSet` takes them. */ +function chainParamSets( + chainId: number, +): Array<{ index: number; encoded: string }> { + return bfvParamSetConfigsForChain(chainId).map((config) => ({ + index: config.paramSet, + encoded: encodeBfvParams(BFV_PRESETS[config.preset].threshold), + })); +} + const interfoldInterface = InterfoldFactory.createInterface(); const releaseInterface = NodeReleaseRegistryFactory.createInterface(); const crispInterface = new ethersLib.Interface([ @@ -175,8 +186,8 @@ export interface V19CutoverDecisions { interfold: string; interfoldProxyAdmin: string; interfoldImplementation: string; - /** Present when parameter set `SECURE_PARAM_SET` is not registered yet. */ - paramSet?: { index: number; encoded: string }; + /** The chain's parameter sets that are not registered yet. */ + paramSets: Array<{ index: number; encoded: string }>; committeeThresholds: Array<{ size: bigint; quorum: bigint; total: bigint }>; pkVerifier: string; decryptionVerifier: string; @@ -215,13 +226,8 @@ export function buildV19CutoverTransactions( decisions.interfold, interfoldInterface.encodeFunctionData(functionName as any, args as any), ); - if (decisions.paramSet) { - txs.push( - call("setParamSet", [ - decisions.paramSet.index, - decisions.paramSet.encoded, - ]), - ); + for (const paramSet of decisions.paramSets) { + txs.push(call("setParamSet", [paramSet.index, paramSet.encoded])); } for (const threshold of decisions.committeeThresholds) { txs.push( @@ -617,16 +623,17 @@ export async function prepareV19Cutover(): Promise { requiredNodeGeneration, ); - const encodedParams = encodeBfvParams(BFV_PARAMS.secure8192); - const registeredParams: string = - await interfold.paramSetRegistry(SECURE_PARAM_SET); - if ( - registeredParams !== "0x" && - registeredParams.toLowerCase() !== encodedParams.toLowerCase() - ) { - throw new Error( - `Parameter set ${SECURE_PARAM_SET} is registered with other values; registration is append-only, so this deployment cannot take the v0.19 parameters`, - ); + // Sepolia requests use the insecure set too, so the batch registers every set the chain lacks. + const missingParamSets: V19CutoverDecisions["paramSets"] = []; + for (const paramSet of chainParamSets(chainId)) { + const registered: string = await interfold.paramSetRegistry(paramSet.index); + if (registered === "0x") { + missingParamSets.push(paramSet); + } else if (registered.toLowerCase() !== paramSet.encoded.toLowerCase()) { + throw new Error( + `Parameter set ${paramSet.index} is registered with other values; registration is append-only, so this deployment cannot take the release's parameters`, + ); + } } const thresholds: V19CutoverDecisions["committeeThresholds"] = []; @@ -708,10 +715,7 @@ export async function prepareV19Cutover(): Promise { interfold: deployment.interfold, interfoldProxyAdmin: deployment.interfoldProxyAdmin, interfoldImplementation: upgrade.implementation, - paramSet: - registeredParams === "0x" - ? { index: SECURE_PARAM_SET, encoded: encodedParams } - : undefined, + paramSets: missingParamSets, committeeThresholds: thresholds, pkVerifier: routes.pkVerifier, decryptionVerifier: routes.decryptionVerifier, @@ -732,7 +736,7 @@ export async function prepareV19Cutover(): Promise { const rawBatchFile = batchPath(config, "cutover"); const title = `${config.name} v0.19 cutover`; const description = - "Upgrade Interfold, register the secure BFV parameters, install the BFV routers, wire the OpenVM CRISP program and raise the node release while requests stay paused."; + "Upgrade Interfold, register the BFV parameters, install the BFV routers, wire the OpenVM CRISP program and raise the node release while requests stay paused."; const batch = governanceBatch(config, txs); batch.meta.name = title; batch.meta.description = description; @@ -766,8 +770,7 @@ export async function prepareV19Cutover(): Promise { nodeRelease, nodeReleasePolicyUpdated, cryptoConfigId: PRODUCTION_BFV_CONFIG.configId, - paramSet: SECURE_PARAM_SET, - paramSetRegisteredByBatch: registeredParams === "0x", + paramSetsRegisteredByBatch: missingParamSets.map(({ index }) => index), pkVerifier: routes.pkVerifier, decryptionVerifier: routes.decryptionVerifier, bfvVerifierRoutes: routes.bfvVerifierRoutes, @@ -834,7 +837,7 @@ v0.19 cutover prepared PK verifier router: ${plan.pkVerifier} decryption router: ${plan.decryptionVerifier} BFV routes: ${plan.bfvVerifierRoutes.length} - parameter set ${plan.paramSet}: ${plan.paramSetRegisteredByBatch ? "registered by the batch" : "already registered"} + parameter sets: ${plan.paramSetsRegisteredByBatch.length ? `${plan.paramSetsRegisteredByBatch.join(", ")} registered by the batch` : "already registered"} CRISP program: ${plan.crispProgram} (image ${plan.crispImageId}) ciphertext verifier: ${plan.ciphertextVerifier} retired E3 programs: ${plan.retiredE3Programs.join(", ") || "none"} @@ -884,11 +887,13 @@ export async function validateV19Cutover(): Promise { plan.cryptoConfigId, "Interfold crypto configuration", ); - equalValue( - await interfold.paramSetRegistry(plan.paramSet), - encodeBfvParams(BFV_PARAMS.secure8192), - `parameter set ${plan.paramSet}`, - ); + for (const paramSet of chainParamSets(chainId)) { + equalValue( + await interfold.paramSetRegistry(paramSet.index), + paramSet.encoded, + `parameter set ${paramSet.index}`, + ); + } for (const threshold of config.interfold.committeeThresholds) { const size = BigInt(threshold.size); equalValue( diff --git a/packages/interfold-contracts/test/Deployment/V19Cutover.spec.ts b/packages/interfold-contracts/test/Deployment/V19Cutover.spec.ts index 05c5bc3e80..fbc782185d 100644 --- a/packages/interfold-contracts/test/Deployment/V19Cutover.spec.ts +++ b/packages/interfold-contracts/test/Deployment/V19Cutover.spec.ts @@ -32,7 +32,7 @@ function decisions() { interfold: addr(1), interfoldProxyAdmin: addr(2), interfoldImplementation: addr(3), - paramSet: { index: 2, encoded: "0x1234" }, + paramSets: [{ index: 3, encoded: "0x1234" }], committeeThresholds: [{ size: 2n, quorum: 9n, total: 20n }], pkVerifier: addr(4), decryptionVerifier: addr(5), @@ -84,7 +84,7 @@ describe("v0.19 cutover", function () { it("leaves out the steps that the chain already satisfies", function () { const txs = buildV19CutoverTransactions({ ...decisions(), - paramSet: undefined, + paramSets: [], committeeThresholds: [], ciphertextVerifier: undefined, registerProgram: undefined, @@ -98,6 +98,24 @@ describe("v0.19 cutover", function () { ]); }); + it("registers every parameter set that the chain lacks", function () { + const paramSets = [ + { index: 4, encoded: "0x12" }, + { index: 3, encoded: "0x34" }, + ]; + const registered = buildV19CutoverTransactions({ + ...decisions(), + paramSets, + }) + .map((tx) => interfoldInterface.parseTransaction({ data: tx.data })) + .filter((parsed) => parsed?.name === "setParamSet") + .map((parsed) => ({ + index: Number(parsed!.args[0]), + encoded: parsed!.args[1], + })); + expect(registered).to.deep.equal(paramSets); + }); + it("reads an OpenVM guest identity and refuses a malformed one", function () { const dir = fs.mkdtempSync(path.join(os.tmpdir(), "v19-identity-")); const good = path.join(dir, "good.json"); From a30bb53e56a7d4b34fb083251cccf729340bd829 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:28:36 +0000 Subject: [PATCH 4/8] docs(blueprint): follow the indexer listener after the historical parameter-set branch --- scripts/blueprint/refs/A-system-apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/blueprint/refs/A-system-apps.json b/scripts/blueprint/refs/A-system-apps.json index ce5c8c6d12..879fb56ba4 100644 --- a/scripts/blueprint/refs/A-system-apps.json +++ b/scripts/blueprint/refs/A-system-apps.json @@ -134,7 +134,7 @@ "supported": true, "refs": [ "crates/evm/indexer/src/indexer.rs@395@create_contract_listener(rpc_url, addresses)", - "crates/evm/indexer/src/indexer.rs@1109@event_listener.listen()" + "crates/evm/indexer/src/indexer.rs@1141@event_listener.listen()" ], "line_text": [ "let event_listener = EventListener::create_contract_listener(rpc_url, addresses).await?;", From 8479ea19a61abf24e4e981e7d3a0e02ad148b4cb Mon Sep 17 00:00:00 2001 From: ctrlc03 Date: Sat, 21 Nov 2026 12:06:21 +0000 Subject: [PATCH 5/8] chore(bfv): register the synchronized secure profile under parameter set 3 sync-secure-8192 takes the SS secure threshold preset, so it follows that preset's move to registry index 3, as sync-insecure-64 already follows index 4. --- packages/interfold-contracts/crypto-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interfold-contracts/crypto-config.json b/packages/interfold-contracts/crypto-config.json index 77f51c58f4..f0896c09b6 100644 --- a/packages/interfold-contracts/crypto-config.json +++ b/packages/interfold-contracts/crypto-config.json @@ -225,7 +225,7 @@ "profile": "sync-secure-8192", "protocol": "synchronized", "statementVersion": "interfold-bfv-v5", - "paramSet": 2, + "paramSet": 3, "threshold": { "name": "SECURE_THRESHOLD_8192", "degree": "8192", From 7892192aa3bd4353b6f7673a61490d619de47729 Mon Sep 17 00:00:00 2001 From: ctrlc03 Date: Sat, 21 Nov 2026 12:08:59 +0000 Subject: [PATCH 6/8] docs(blueprint): follow the parameter-preset and indexer refs moved by the rebase onto main --- .../blueprint/facts/02-clients-compute.json | 22 +++++++++---------- scripts/blueprint/facts/09-foundations.json | 10 ++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/blueprint/facts/02-clients-compute.json b/scripts/blueprint/facts/02-clients-compute.json index 2921254ed7..af17b3a784 100644 --- a/scripts/blueprint/facts/02-clients-compute.json +++ b/scripts/blueprint/facts/02-clients-compute.json @@ -336,27 +336,27 @@ { "name": "CommitteePublished log", "by": "InterfoldIndexer", - "ref": "crates/evm/indexer/src/indexer.rs@657@move |e: CommitteePublished, ctx| async move {" + "ref": "crates/evm/indexer/src/indexer.rs@689@move |e: CommitteePublished, ctx| async move {" }, { "name": "CommitteePublicKeyChunkPublished log", "by": "InterfoldIndexer", - "ref": "crates/evm/indexer/src/indexer.rs@669@move |event: CommitteePublicKeyChunkPublished, ctx| async move {" + "ref": "crates/evm/indexer/src/indexer.rs@701@move |event: CommitteePublicKeyChunkPublished, ctx| async move {" }, { "name": "CiphertextOutputPublished log", "by": "InterfoldIndexer", - "ref": "crates/evm/indexer/src/indexer.rs@745@self.add_event_handler(move |e: CiphertextOutputPublished, ctx| async move {" + "ref": "crates/evm/indexer/src/indexer.rs@777@self.add_event_handler(move |e: CiphertextOutputPublished, ctx| async move {" }, { "name": "CiphertextOutputReferencePublished log", "by": "InterfoldIndexer", - "ref": "crates/evm/indexer/src/indexer.rs@768@move |event: CiphertextOutputReferencePublished, ctx| async move {" + "ref": "crates/evm/indexer/src/indexer.rs@800@move |event: CiphertextOutputReferencePublished, ctx| async move {" }, { "name": "PlaintextOutputPublished log", "by": "InterfoldIndexer", - "ref": "crates/evm/indexer/src/indexer.rs@790@self.add_event_handler(move |e: PlaintextOutputPublished, ctx| async move {" + "ref": "crates/evm/indexer/src/indexer.rs@822@self.add_event_handler(move |e: PlaintextOutputPublished, ctx| async move {" } ], "emits": [], @@ -411,19 +411,19 @@ }, { "why": "construction: reads the chain id, wires the listeners and registers the handlers", - "ref": "crates/evm/indexer/src/indexer.rs@555@pub async fn new(" + "ref": "crates/evm/indexer/src/indexer.rs@587@pub async fn new(" }, { "why": "opt-in catch-up and cursor, with the reason for the opt-in in the doc", - "ref": "crates/evm/indexer/src/indexer.rs@910@pub fn configure_backfill(&self, start_block: Option, chunk: Option) {" + "ref": "crates/evm/indexer/src/indexer.rs@942@pub fn configure_backfill(&self, start_block: Option, chunk: Option) {" }, { "why": "committee key handling: the on-chain commitment check before storage", - "ref": "crates/evm/indexer/src/indexer.rs@477@if let Err(error) = validate_pk_commitment(" + "ref": "crates/evm/indexer/src/indexer.rs@509@if let Err(error) = validate_pk_commitment(" }, { "why": "the live loop: backfill, subscribe, overlap replay, restart on error", - "ref": "crates/evm/indexer/src/indexer.rs@1007@pub async fn listen(&self) -> Result<()> {" + "ref": "crates/evm/indexer/src/indexer.rs@1039@pub async fn listen(&self) -> Result<()> {" } ], "rust_patterns": [ @@ -440,12 +440,12 @@ { "pattern": "tokio-select", "note": "listen() races the event listener, the block listener and the overlap replay, and restarts when one ends", - "ref": "crates/evm/indexer/src/indexer.rs@1108@let res = tokio::select! {" + "ref": "crates/evm/indexer/src/indexer.rs@1140@let res = tokio::select! {" }, { "pattern": "arc-shared", "note": "handlers hold a Weak reference to the context, so the context and its listeners can be dropped", - "ref": "crates/evm/indexer/src/indexer.rs@603@let ctx_weak = Arc::downgrade(&ctx);" + "ref": "crates/evm/indexer/src/indexer.rs@635@let ctx_weak = Arc::downgrade(&ctx);" } ], "depends_on": ["e3-bfv-client", "e3-data-availability", "e3-evm-client", "e3-evm-contracts", "e3-fhe-params"], diff --git a/scripts/blueprint/facts/09-foundations.json b/scripts/blueprint/facts/09-foundations.json index de70831de1..146fc3d392 100644 --- a/scripts/blueprint/facts/09-foundations.json +++ b/scripts/blueprint/facts/09-foundations.json @@ -71,12 +71,12 @@ { "name": "BfvParamSet", "what": "one preset's degree, plaintext modulus and moduli, ready to build BFV parameters", - "ref": "crates/bfv/params/src/presets.rs@249@pub struct BfvParamSet {" + "ref": "crates/bfv/params/src/presets.rs@267@pub struct BfvParamSet {" }, { "name": "PresetError", "what": "error type: unknown preset, missing threshold or DKG pair, or an insecure lambda", - "ref": "crates/bfv/params/src/presets.rs@206@pub enum PresetError {" + "ref": "crates/bfv/params/src/presets.rs@222@pub enum PresetError {" } ], "read_first": [ @@ -101,17 +101,17 @@ { "pattern": "enum-match", "note": "metadata() maps each preset to its degree, modulus count, party count and security tier", - "ref": "crates/bfv/params/src/presets.rs@387@pub fn metadata(&self) -> PresetMetadata" + "ref": "crates/bfv/params/src/presets.rs@418@pub fn metadata(&self) -> PresetMetadata" }, { "pattern": "thiserror-enum", "note": "PresetError derives Debug and the thiserror Error impl through the ThisError alias", - "ref": "crates/bfv/params/src/presets.rs@205@#[derive(ThisError, Debug)]" + "ref": "crates/bfv/params/src/presets.rs@221@#[derive(ThisError, Debug)]" }, { "pattern": "impl-from", "note": "a preset converts into its BfvParamSet with From", - "ref": "crates/bfv/params/src/presets.rs@497@impl From for BfvParamSet {" + "ref": "crates/bfv/params/src/presets.rs@569@impl From for BfvParamSet {" }, { "pattern": "builder-pattern", From 79f015a647d875edf45a24822a75c4bb1b7c19cb Mon Sep 17 00:00:00 2001 From: ctrlc03 Date: Sat, 21 Nov 2026 14:18:38 +0000 Subject: [PATCH 7/8] test(indexer): read a historical parameter-set slot from the registry Pre-cutover E3s at slots 0 and 2 now resolve through the registry bytes rather than a local preset. The fake Interfold gains setParamSet, and a backfill test registers the historical insecure v5 tuple at slot 0: a request under its threshold-only ID is stored with those exact bytes, and a request under another ID at the slot is skipped. --- Cargo.lock | 1 + crates/evm/indexer/Cargo.toml | 1 + .../indexer/tests/fixtures/fake_interfold.sol | 4 + crates/evm/indexer/tests/integration.rs | 88 +++++++++++++++++++ 4 files changed, 94 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c01cb725d6..1d679d0416 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4166,6 +4166,7 @@ dependencies = [ "fhe-traits", "rand 0.9.5", "serde", + "serde_json", "thiserror 1.0.69", "tokio", "tracing", diff --git a/crates/evm/indexer/Cargo.toml b/crates/evm/indexer/Cargo.toml index 7ba3123f84..cf5f6c0811 100644 --- a/crates/evm/indexer/Cargo.toml +++ b/crates/evm/indexer/Cargo.toml @@ -26,3 +26,4 @@ tracing.workspace = true fhe.workspace = true fhe-traits.workspace = true rand.workspace = true +serde_json.workspace = true diff --git a/crates/evm/indexer/tests/fixtures/fake_interfold.sol b/crates/evm/indexer/tests/fixtures/fake_interfold.sol index 4657996fbd..e3fb22ceb0 100644 --- a/crates/evm/indexer/tests/fixtures/fake_interfold.sol +++ b/crates/evm/indexer/tests/fixtures/fake_interfold.sol @@ -28,6 +28,10 @@ contract FakeInterfold { mapping(uint256 => bytes32) private encryptionSchemeOverrides; mapping(uint256 => uint8) private paramSetOverrides; + function setParamSet(uint8 index, bytes calldata data) external { + paramSetRegistry[index] = data; + } + function setCryptoConfigId(uint256 e3Id, bytes32 configId) external { cryptoConfigOverrides[e3Id] = configId; } diff --git a/crates/evm/indexer/tests/integration.rs b/crates/evm/indexer/tests/integration.rs index c8efb8b750..02520b45af 100644 --- a/crates/evm/indexer/tests/integration.rs +++ b/crates/evm/indexer/tests/integration.rs @@ -274,6 +274,94 @@ async fn backfill_skips_legacy_keys_and_recovers_current_rounds() -> Result<()> Ok(()) } +/// A request at a historical registry slot resolves to the registry's bytes under the +/// threshold-only ID those bytes had, and any other ID at that slot is skipped. +#[tokio::test] +async fn backfill_reads_historical_slots_from_the_registry() -> Result<()> { + let (contract, address, _, _, endpoint, _anvil) = setup_two_contracts().await?; + let vectors: serde_json::Value = serde_json::from_str(include_str!( + "../../../bfv/params/tests/fixtures/bfv_protocol.json" + ))?; + let vector = |name: &str| { + vectors["vectors"] + .as_array() + .and_then(|all| all.iter().find(|v| v["name"] == name)) + .unwrap_or_else(|| panic!("fixture vector {name}")) + .clone() + }; + let historical = vector("historical-insecure-v5"); + assert_eq!(historical["paramSet"], 0); + let params: Bytes = historical["encodedParameters"].as_str().unwrap().parse()?; + let historical_id: B256 = historical["cryptoConfigId"].as_str().unwrap().parse()?; + let other_id: B256 = vector("current-insecure")["cryptoConfigId"] + .as_str() + .unwrap() + .parse()?; + // A non-BFV scheme keeps the committee-key binding out of the test. + let scheme = alloy::primitives::keccak256("AES-256-GCM"); + contract + .setParamSet(0, params.clone()) + .send() + .await? + .watch() + .await?; + let (historical_e3, mismatched_e3) = (21u64, 22u64); + for (id, config_id) in [(historical_e3, historical_id), (mismatched_e3, other_id)] { + contract + .setRequestCrypto(Uint::from(id), scheme, 0, config_id) + .send() + .await? + .watch() + .await?; + contract + .emitCommitteePublished( + Uint::from(id), + Bytes::from(vec![1, 2, 3]), + B256::ZERO, + Bytes::default(), + ) + .send() + .await? + .watch() + .await?; + } + + let indexer = Arc::new( + InterfoldIndexer::::from_endpoint_address_in_mem( + &endpoint, + &[&address], + ) + .await?, + ); + indexer.configure_backfill(Some(0), Some(2)); + let listener = { + let indexer = indexer.clone(); + tokio::spawn(async move { indexer.listen().await }) + }; + let recovered = tokio::time::timeout(Duration::from_secs(5), async { + loop { + if let Ok(round) = indexer.get_e3(historical_e3).await { + if indexer + .get_store() + .get::(e3_indexer::INDEXER_CURSOR_KEY) + .await? + .is_some() + { + break Ok::<_, eyre::Report>(round); + } + } + sleep(Duration::from_millis(10)).await; + } + }) + .await; + listener.abort(); + let round = recovered??; + assert_eq!(round.e3_params, params.to_vec()); + assert_eq!(round.crypto_config_id, historical_id.to_vec()); + assert!(indexer.get_e3(mismatched_e3).await.is_err()); + Ok(()) +} + mod test_memory_leak { use e3_evm_client::{contracts::InterfoldContractFactory, event_listener::EventListener}; From 5300997b9e69831ad7d3ca16a4211ff4e7164ace Mon Sep 17 00:00:00 2001 From: ctrlc03 Date: Sat, 21 Nov 2026 14:19:02 +0000 Subject: [PATCH 8/8] docs(upgrades): correct the parameter-set registry facts Sepolia index 0 holds the degree-64 v5 tuple of a later redeployment, not the v0.19.x tuple; a fresh Mainnet deployment registers index 3 only; an unregistered historical index fails as not registered before the crypto-config check; clients derive the index from bfvConfiguration in @interfold/contracts/bfv, since the SDK does not export ParamSet; and a rollback leaves indices 3 and 4 registered but inert. --- docs/architecture/upgrades.md | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/docs/architecture/upgrades.md b/docs/architecture/upgrades.md index 1c3ca5e996..73d0323bcf 100644 --- a/docs/architecture/upgrades.md +++ b/docs/architecture/upgrades.md @@ -267,7 +267,8 @@ ID, and every verification key and verifier. DKG tuples are unchanged. **The tup registry indices: secure-8192 to index 3 and insecure-64 to index 4.** `setParamSet` is append-only, and live registries hold earlier tuples at indices 0–2: Mainnet index 0 (`0x18c6d865…7b4f`, degree-512 v1), index 1 (`0xd7068fdc…43ec`, v1 secure) and index 2 (`0x1b2620f6…2317`, v0.19 -secure); Sepolia index 0 (`0xaff065a7…ab1e`, v0.19 insecure) and index 2 (`0x1b2620f6…2317`). +secure); Sepolia index 0 (`0xaff065a7…ab1e`, the degree-64 v5 tuple of the later Sepolia +redeployment; the v0.19.x tags shipped the degree-512 tuple there) and index 2 (`0x1b2620f6…2317`). Indices 3 and 4 are empty on both. Reusing an index is not possible and would not be safe: `setParamSet` reverts `ParamSetAlreadyRegistered`, and `requestE3` does not compare the registered bytes with the `BfvProtocol` hash, so it would hand the old bytes to the E3 program and bind their @@ -275,19 +276,23 @@ hash for the ciphertext verifier while nodes prove with the new tuple. Cutover procedure, in the paused/drained governance batch that upgrades Interfold and its linked `ActiveCryptoConfig`: call `setParamSet(3, …)` with the secure tuple on Mainnet and Sepolia, and -`setParamSet(4, …)` with the insecure tuple on Sepolia. A fresh deployment registers both through -`registerActiveBfvParamSet`. `upgrade:v19` prepares each index that the chain lacks, and its -`validate` checks them. Before resume, check that `keccak256(paramSetRegistry(3))` is -`BfvProtocol.SECURE_PARAM_SET_HASH` (`0x4f402598…08c3`), that `keccak256(paramSetRegistry(4))` is -`INSECURE_PARAM_SET_HASH` (`0x2898f8a9…a844`), and that indices 0, 1 and 2 still hold the bytes -above. Never overwrite or reinterpret indices 0, 1 and 2. After the upgrade `getE3Quote` and -`request` revert `UnsupportedCryptoConfig` for them, and nodes skip any request event that names -them. Clients derive the index from the profile (`ParamSet` in `@interfold/sdk`, -`BFV_PRESETS[…].paramSet` in `@interfold/contracts`); a client that hard-codes 0 or 2, such as the -CRISP server `E3_PARAM_SET`, must change with the release. The indexer resolves indices 3 and 4 only -through a current profile identity. It reads indices 0, 1 and 2 from the append-only registry bytes -and accepts only the frozen threshold-only ID of those exact bytes: v5 at indices 0 and 2, v1 at -indices 0 and 1. `crates/bfv/params/tests/fixtures/bfv_protocol.json` freezes these vectors. +`setParamSet(4, …)` with the insecure tuple on Sepolia. A fresh deployment registers the chain's +sets through `registerActiveBfvParamSet`: index 3 on Mainnet, indices 3 and 4 on Sepolia and local +chains. `upgrade:v19` prepares each index that the chain lacks, and its `validate` checks them. +Before resume, check that `keccak256(paramSetRegistry(3))` is `BfvProtocol.SECURE_PARAM_SET_HASH` +(`0x4f402598…08c3`), that `keccak256(paramSetRegistry(4))` is `INSECURE_PARAM_SET_HASH` +(`0x2898f8a9…a844`), and that indices 0, 1 and 2 still hold the bytes above. Never overwrite or +reinterpret indices 0, 1 and 2. After the upgrade `getE3Quote` and `request` revert +`UnsupportedCryptoConfig` for a registered one of them (an unregistered index, such as Sepolia's 1, +fails earlier with `BFV param set not registered`), and nodes skip any request event that names +them. Clients derive the index from the profile (`bfvConfiguration(profile, committeeSize).paramSet` +from `@interfold/contracts/bfv`); a client that hard-codes 0 or 2, such as the CRISP server +`E3_PARAM_SET`, must change with the release. Rollback cannot remove the registrations: after a +rollback indices 3 and 4 stay registered but inert, because the earlier implementation does not +route them. The indexer resolves indices 3 and 4 only through a current profile identity. It reads +indices 0, 1 and 2 from the append-only registry bytes and accepts only the frozen threshold-only ID +of those exact bytes: v5 at indices 0 and 2, v1 at indices 0 and 1. +`crates/bfv/params/tests/fixtures/bfv_protocol.json` freezes these vectors. The DKG runtime slice changes local C1/C2/C4 and native-generation request/response encodings, `ThresholdSharePending` (optional SS lane plus encrypted own rows), and keyshare recovery (optional