mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
B-Chain does NOT do threshold custody keygen/signing. Custody is M-Chain's job: dealerless CGGMP21/FROST distributed keygen via luxfi/threshold (cmp.Keygen/frost.Keygen — multi-round protocols over a message router; no trusted dealer, the group secret is never assembled by any validator). B-Chain requests keygen/reshare/sign from M-Chain over Warp (CrossChainMPCRequest) and only VERIFIES the resulting CMP threshold signatures (block.Verify → mpcConfig, accel_verify.go). bridgevm carried a SECOND, parallel MPC subsystem — a BLS MPCKeyManager that did its own in-VM keygen (until this session, via a trusted dealer) feeding BridgeSigner/DeliveryConfirmationSigner/BridgeMessageValidator. It duplicated custody, used the wrong scheme (BLS vs the live CMP path), and was never in block.Verify. Deleted entirely — one and one way. Removed: - mpc.go (MPCKeyManager, SigningSession) - bridge_signing.go (BridgeSigner, DeliveryConfirmationSigner, BridgeMessageValidator, MPCCoordinator, BridgeMessage/DeliveryConfirmation) - vm_mpc_integration.go (InitializeMPCKeys, TriggerKeygen, ProcessBridgeMessage) - vm.go: the 5 BLS fields + their init block (no key material is generated on B-Chain now) - feegate.go: gateUserBridgeMessage (BLS-message fee gate) → replaced by gateUserBridgeFee(uint64) on the live path (LP-0130 §8) Relocated / repointed: - ErrInvalidBridgeSignature → accel_verify.go (the live CMP verify path) - rpc.go MPCReady/MPCPublicKey → vm.mpcGroupPublicKey() (reads the CMP custody group point from mpcConfig, i.e. M-Chain's key), never a B-Chain-held secret Build + vet + full bridgevm tests green. Co-authored-by: Hanzo Dev <[email protected]>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package bridgevm
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/node/vms/types/fee"
|
|
)
|
|
|
|
// newFeePolicy returns the canonical B-Chain FeePolicy. B-Chain accepts
|
|
// user-submitted bridge transfers (InitiateBridgeTransfer) that drive
|
|
// MPC signing capacity, so it MUST charge a non-zero floor; see
|
|
// vms/types/fee/policy.go.
|
|
func newFeePolicy(networkID uint32) fee.Policy {
|
|
return fee.FlatPolicy{
|
|
Fee: fee.MinTxFeeFloor,
|
|
AssetID: constants.UTXOAssetIDFor(networkID),
|
|
}
|
|
}
|
|
|
|
// gateUserBridgeFee refuses a bridge transfer whose declared fee does not
|
|
// satisfy the configured FeePolicy (LP-0130 §8: B-Chain fees). Called on
|
|
// the user-tx entry before any M-Chain signing capacity is consumed.
|
|
func (vm *VM) gateUserBridgeFee(paid uint64) error {
|
|
if vm.feePolicy == nil {
|
|
return fmt.Errorf("bridgevm: fee policy not initialized")
|
|
}
|
|
return vm.feePolicy.ValidateFee(paid, constants.UTXOAssetIDFor(vm.networkID))
|
|
}
|
|
|
|
// FeePolicy exposes the chain's declared fee policy for diagnostics
|
|
// and the boot-time Validate gate.
|
|
func (vm *VM) FeePolicy() fee.Policy { return vm.feePolicy }
|
|
|
|
// mpcGroupPublicKey returns the serialized CGGMP21 custody group public key
|
|
// (established by M-Chain's dealerless keygen), or nil if keygen has not
|
|
// completed. B-Chain never holds a custody secret — only this public point.
|
|
func (vm *VM) mpcGroupPublicKey() []byte {
|
|
if vm.mpcConfig == nil {
|
|
return nil
|
|
}
|
|
pt := vm.mpcConfig.PublicPoint()
|
|
if pt == nil {
|
|
return nil
|
|
}
|
|
b, err := pt.MarshalBinary()
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return b
|
|
}
|